-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from XantreGodlike/safe-signals-runtime
Safe signals runtime early implementation
- Loading branch information
Showing
80 changed files
with
4,726 additions
and
1,262 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@preact-signals/safe-react": patch | ||
--- | ||
|
||
Package init |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@preact-signals/utils": patch | ||
--- | ||
|
||
Removed unnecessary private varitables usage from hocs entry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@preact-signals/unified-signals": patch | ||
"@preact-signals/query": patch | ||
"@preact-signals/utils": patch | ||
--- | ||
|
||
Added `@preact-signals/safe-react` as peerDependency |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@preact-signals/query": minor | ||
--- | ||
|
||
Removed incorrect `@trackSignals` directives for `@preact/signals-react-transform` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
packages/query/src/__tests__/standart-query | ||
node_modules | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"parser": "@typescript-eslint/parser", | ||
"plugins": ["@typescript-eslint"], | ||
"parserOptions": { | ||
"project": ["./tsconfig.json"] // Specify it only for TypeScript files | ||
}, | ||
"rules": { | ||
"@typescript-eslint/no-floating-promises": [ | ||
"error", | ||
{ | ||
"ignoreVoid": true | ||
} | ||
] | ||
}, | ||
"root": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,85 @@ | ||
import react from "@vitejs/plugin-react-swc"; | ||
import { defineConfig } from "vite"; | ||
import reactBabel from "@vitejs/plugin-react"; | ||
import babel from "vite-plugin-babel"; | ||
import { PluginOption, defineConfig } from "vite"; | ||
import { z } from "zod"; | ||
import { createRequire } from "node:module"; | ||
import path from "node:path"; | ||
|
||
const resolve = createRequire(import.meta.url).resolve; | ||
|
||
const envSchema = z | ||
.object({ | ||
USE_TRANSFORM: z.enum(["0", "1"]), | ||
}) | ||
.transform((it) => ({ | ||
USE_TRANSFORM: it.USE_TRANSFORM === "0" ? false : true, | ||
})); | ||
const { USE_TRANSFORM } = envSchema.parse(process.env); | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [react()], | ||
resolve: USE_TRANSFORM | ||
? { | ||
alias: [ | ||
{ | ||
find: /^react$/, | ||
replacement: "@preact-signals/safe-react/react", | ||
// TODO: extract to lib | ||
customResolver: (() => { | ||
const reactUrl = resolve("react"); | ||
const fakeUrl = resolve("@preact-signals/safe-react/react"); | ||
return { | ||
resolveId(source, importer) { | ||
const useRealImport = importer?.endsWith("react.cjs"); | ||
return useRealImport ? reactUrl : fakeUrl; | ||
}, | ||
}; | ||
})(), | ||
}, | ||
{ | ||
find: "@preact/signals-react", | ||
replacement: path.resolve( | ||
resolve("@preact-signals/safe-react"), | ||
"../../esm/index.mjs" | ||
), | ||
}, | ||
], | ||
} | ||
: undefined, | ||
plugins: [ | ||
USE_TRANSFORM && | ||
babel({ | ||
babelConfig: { | ||
plugins: [ | ||
"@babel/plugin-syntax-jsx", | ||
[ | ||
"module:@preact/signals-react-transform", | ||
{ | ||
importSource: "@preact-signals/safe-react", | ||
}, | ||
], | ||
], | ||
}, | ||
filter: /utils\/dist\/.+\.mjs$/, | ||
}), | ||
, | ||
reactBabel( | ||
USE_TRANSFORM | ||
? { | ||
jsxImportSource: "@preact-signals/safe-react", | ||
babel: { | ||
plugins: [ | ||
[ | ||
"module:@preact/signals-react-transform", | ||
{ | ||
importSource: "@preact-signals/safe-react", | ||
}, | ||
], | ||
], | ||
}, | ||
include: /\.(mdx|js|jsx|ts|tsx)$/, | ||
} | ||
: undefined | ||
) as PluginOption[], | ||
].filter(Boolean), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.