xanix 1.0.20 → 1.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/bundler/cache/buildCache.js +9 -11
- package/dist/bin/bundler/cache/index.js +70 -116
- package/dist/bin/bundler/cache/utils.d.ts +3 -2
- package/dist/bin/bundler/cache/utils.js +27 -24
- package/dist/bin/bundler/client/build.js +1 -1
- package/dist/bin/bundler/client/plugins/Transformer/TransformCacheFunction copy.d.ts +3 -0
- package/dist/bin/bundler/client/plugins/Transformer/TransformCacheFunction copy.js +32 -0
- package/dist/bin/bundler/client/plugins/Transformer/TransformCacheFunction.d.ts +1 -1
- package/dist/bin/bundler/client/plugins/Transformer/TransformCacheFunction.js +1 -1
- package/dist/bin/bundler/client/plugins/Transformer/TransformCreateSession.d.ts +1 -1
- package/dist/bin/bundler/client/plugins/Transformer/TransformCreateSession.js +1 -1
- package/dist/bin/bundler/client/plugins/Transformer/TransformDevModule.d.ts +13 -0
- package/dist/bin/bundler/client/plugins/Transformer/{transformModuleCache.js → TransformDevModule.js} +6 -18
- package/dist/bin/bundler/client/plugins/Transformer/TransformServerFunction.d.ts +1 -1
- package/dist/bin/bundler/client/plugins/Transformer/TransformServerFunction.js +1 -1
- package/dist/bin/bundler/client/plugins/Transformer/cacheFunctionReplacer.d.ts +3 -0
- package/dist/bin/bundler/client/plugins/Transformer/cacheFunctionReplacer.js +32 -0
- package/dist/bin/bundler/client/plugins/Transformer/cacheFunctionTransformer.d.ts +3 -0
- package/dist/bin/bundler/client/plugins/Transformer/cacheFunctionTransformer.js +32 -0
- package/dist/bin/bundler/client/plugins/Transformer/serverFunctionReplacer.d.ts +3 -0
- package/dist/bin/bundler/client/plugins/Transformer/serverFunctionReplacer.js +32 -0
- package/dist/bin/bundler/client/plugins/Transformer/useServerReplacer.d.ts +3 -0
- package/dist/bin/bundler/client/plugins/Transformer/useServerReplacer.js +42 -0
- package/dist/bin/bundler/client/plugins/Transformer.js +4 -2
- package/dist/bin/bundler/client/plugins/XanixAppRoot.d.ts +2 -0
- package/dist/bin/bundler/client/plugins/XanixAppRoot.js +46 -0
- package/dist/bin/bundler/client/plugins/XanixPage.js +30 -0
- package/dist/bin/bundler/client/plugins/XanixPages.js +8 -8
- package/dist/bin/bundler/client/plugins/replacer/cacheFunctionReplacer.d.ts +1 -1
- package/dist/bin/bundler/client/plugins/replacer/cacheFunctionReplacer.js +5 -1
- package/dist/bin/bundler/client/plugins/replacer/serverFunctionReplacer.d.ts +1 -1
- package/dist/bin/bundler/client/plugins/replacer/serverFunctionReplacer.js +5 -1
- package/dist/bin/bundler/client/plugins/replacer/useServerReplacer.d.ts +1 -1
- package/dist/bin/bundler/client/plugins/replacer/useServerReplacer.js +7 -3
- package/dist/bin/bundler/server/build.js +1 -1
- package/dist/bin/bundler/server/plugins/Transformer/TransformCacheFunction copy.d.ts +3 -0
- package/dist/bin/bundler/server/plugins/Transformer/TransformCacheFunction copy.js +32 -0
- package/dist/bin/bundler/server/plugins/Transformer/TransformCacheFunction.d.ts +1 -1
- package/dist/bin/bundler/server/plugins/Transformer/TransformCacheFunction.js +1 -1
- package/dist/bin/bundler/server/plugins/Transformer/TransformCreateSession.d.ts +1 -1
- package/dist/bin/bundler/server/plugins/Transformer/TransformCreateSession.js +1 -1
- package/dist/bin/bundler/server/plugins/Transformer/TransformExpressFunction.d.ts +1 -1
- package/dist/bin/bundler/server/plugins/Transformer/TransformExpressFunction.js +1 -1
- package/dist/bin/bundler/server/plugins/Transformer/TransformPage.js +1 -1
- package/dist/bin/bundler/server/plugins/Transformer/TransformServerFunction.d.ts +1 -1
- package/dist/bin/bundler/server/plugins/Transformer/TransformServerFunction.js +1 -1
- package/dist/bin/bundler/server/plugins/Transformer/cacheFunctionReplacer.d.ts +3 -0
- package/dist/bin/bundler/server/plugins/Transformer/cacheFunctionReplacer.js +32 -0
- package/dist/bin/bundler/server/plugins/Transformer/expressFunctionReplace.d.ts +3 -0
- package/dist/bin/bundler/server/plugins/Transformer/expressFunctionReplace.js +24 -0
- package/dist/bin/bundler/server/plugins/Transformer/pageReplacer.d.ts +4 -0
- package/dist/bin/bundler/server/plugins/Transformer/pageReplacer.js +31 -0
- package/dist/bin/bundler/server/plugins/Transformer/serverFunctionReplacer.d.ts +3 -0
- package/dist/bin/bundler/server/plugins/Transformer/serverFunctionReplacer.js +32 -0
- package/dist/bin/bundler/server/plugins/Transformer/useServerReplacer.d.ts +3 -0
- package/dist/bin/bundler/server/plugins/Transformer/useServerReplacer.js +42 -0
- package/dist/bin/bundler/server/plugins/Transformer copy.js +3 -3
- package/dist/bin/bundler/server/plugins/Transformer.js +2 -2
- package/dist/bin/bundler/server/plugins/replacer/cacheFunctionReplacer.d.ts +1 -1
- package/dist/bin/bundler/server/plugins/replacer/cacheFunctionReplacer.js +5 -1
- package/dist/bin/bundler/server/plugins/replacer/serverFunctionReplacer copy.d.ts +3 -0
- package/dist/bin/bundler/server/plugins/replacer/serverFunctionReplacer copy.js +26 -0
- package/dist/bin/bundler/server/plugins/replacer/serverFunctionReplacer.d.ts +1 -1
- package/dist/bin/bundler/server/plugins/replacer/serverFunctionReplacer.js +5 -1
- package/dist/bin/bundler/server/plugins/replacer/serverReplacer.d.ts +3 -0
- package/dist/bin/bundler/server/plugins/replacer/serverReplacer.js +26 -0
- package/dist/bin/bundler/server/plugins/replacer/useServerReplacer.d.ts +2 -2
- package/dist/bin/bundler/server/plugins/replacer/useServerReplacer.js +9 -5
- package/dist/bin/cli/dev.js +85 -71
- package/dist/bin/cli/start/index.d.ts +4 -1
- package/dist/bin/cli/start/index.js +60 -9
- package/dist/bin/finder/callbackReplacer.d.ts +2 -0
- package/dist/bin/finder/callbackReplacer.js +52 -0
- package/dist/bin/finder/findImport.d.ts +9 -0
- package/dist/bin/finder/findImport.js +50 -0
- package/dist/bin/finder/findImports.d.ts +16 -0
- package/dist/bin/finder/findImports.js +45 -0
- package/dist/bin/finder/findPage.d.ts +9 -0
- package/dist/bin/finder/findPage.js +30 -0
- package/dist/bin/finder/importFinder.d.ts +9 -0
- package/dist/bin/finder/importFinder.js +50 -0
- package/dist/bin/finder/pageFinder.d.ts +9 -0
- package/dist/bin/finder/pageFinder.js +30 -0
- package/dist/bin/finder/stripComments.d.ts +3 -0
- package/dist/bin/finder/stripComments.js +15 -0
- package/dist/bin/include/path.d.ts +5 -1
- package/dist/bin/include/path.js +15 -1
- package/dist/bin/include/sendFinder.d.ts +4 -1
- package/dist/bin/include/sendFinder.js +88 -53
- package/dist/bin/index.js +0 -0
- package/dist/bin/modifier/callbackReplacer.js +35 -80
- package/dist/bin/modifier/findImports.d.ts +16 -0
- package/dist/bin/modifier/findImports.js +45 -0
- package/dist/bin/modifier/importFinder.js +44 -63
- package/dist/bin/modifier/pageFinder.d.ts +1 -1
- package/dist/bin/modifier/pageFinder.js +19 -124
- package/dist/bin/modifier/sendFinder.d.ts +9 -0
- package/dist/bin/modifier/sendFinder.js +135 -0
- package/dist/bin/modifier/sriptCommnet.d.ts +1 -0
- package/dist/bin/modifier/sriptCommnet.js +12 -5
- package/dist/bin/modifier/stripComments.d.ts +3 -0
- package/dist/bin/modifier/stripComments.js +15 -0
- package/dist/bin/plugins/XanixAssets.js +2 -2
- package/dist/bin/plugins/XanixCss.js +13 -13
- package/dist/bin/plugins/XanixDocument.js +4 -4
- package/dist/components/Head.js +1 -1
- package/dist/hooks/encript.d.ts +2 -0
- package/dist/hooks/encript.js +13 -0
- package/dist/hooks/server.js +2 -2
- package/dist/hooks/session.js +2 -2
- package/dist/index.js +0 -0
- package/dist/libs/encoder.d.ts +2 -0
- package/dist/libs/encoder.js +13 -0
- package/dist/libs/encript.d.ts +2 -0
- package/dist/libs/encript.js +30 -0
- package/dist/navigate.js +1 -1
- package/dist/server/express/Router.js +4 -4
- package/dist/server/express/page.d.ts +1 -1
- package/dist/server/express/page.js +1 -1
- package/dist/types/assets.d.ts +72 -72
- package/dist/types/express.d.ts +11 -11
- package/dist/types/globals.d.ts +18 -18
- package/dist/types/xanix-virtual.d.ts +35 -35
- package/package.json +57 -60
- package/dist/bin/bundler/Cache.d.ts +0 -1
- package/dist/bin/bundler/Cache.js +0 -210
- package/dist/bin/bundler/External.d.ts +0 -3
- package/dist/bin/bundler/External.js +0 -6
- package/dist/bin/bundler/buildClient.d.ts +0 -3
- package/dist/bin/bundler/buildClient.js +0 -42
- package/dist/bin/bundler/buildServer.d.ts +0 -7
- package/dist/bin/bundler/buildServer.js +0 -50
- package/dist/bin/bundler/cache/plugin/Transformer.d.ts +0 -3
- package/dist/bin/bundler/cache/plugin/Transformer.js +0 -42
- package/dist/bin/bundler/client/plugins/Transformer/TransformExpress.d.ts +0 -9
- package/dist/bin/bundler/client/plugins/Transformer/TransformExpress.js +0 -26
- package/dist/bin/bundler/client/plugins/Transformer/TransformPage.d.ts +0 -29
- package/dist/bin/bundler/client/plugins/Transformer/TransformPage.js +0 -77
- package/dist/bin/bundler/client/plugins/Transformer/TransformReactContext.d.ts +0 -17
- package/dist/bin/bundler/client/plugins/Transformer/TransformReactContext.js +0 -101
- package/dist/bin/bundler/client/plugins/Transformer/transformModuleCache.d.ts +0 -15
- package/dist/bin/bundler/client/plugins/Transformer copy.d.ts +0 -3
- package/dist/bin/bundler/client/plugins/Transformer copy.js +0 -70
- package/dist/bin/bundler/client/plugins/VirtualDev.d.ts +0 -2
- package/dist/bin/bundler/client/plugins/VirtualDev.js +0 -34
- package/dist/bin/bundler/client/plugins/XanixReactRefresh.d.ts +0 -2
- package/dist/bin/bundler/client/plugins/XanixReactRefresh.js +0 -22
- package/dist/bin/bundler/config/defines.d.ts +0 -20
- package/dist/bin/bundler/config/defines.js +0 -21
- package/dist/bin/bundler/config/external.d.ts +0 -1
- package/dist/bin/bundler/config/external.js +0 -12
- package/dist/bin/bundler/config/loadEnv.d.ts +0 -20
- package/dist/bin/bundler/config/loadEnv.js +0 -48
- package/dist/bin/bundler/config/output.d.ts +0 -10
- package/dist/bin/bundler/config/output.js +0 -52
- package/dist/bin/bundler/externalResolver-dep.d.ts +0 -3
- package/dist/bin/bundler/externalResolver-dep.js +0 -203
- package/dist/bin/bundler/externalResolver.d.ts +0 -3
- package/dist/bin/bundler/externalResolver.js +0 -203
- package/dist/bin/bundler/plugins/TransformServer/TransformExpress.d.ts +0 -9
- package/dist/bin/bundler/plugins/TransformServer/TransformExpress.js +0 -26
- package/dist/bin/bundler/plugins/TransformServer/TransformPage.d.ts +0 -25
- package/dist/bin/bundler/plugins/TransformServer/TransformPage.js +0 -79
- package/dist/bin/bundler/plugins/TransformServer/index.d.ts +0 -3
- package/dist/bin/bundler/plugins/TransformServer/index.js +0 -103
- package/dist/bin/bundler/plugins/XanixAssets.d.ts +0 -5
- package/dist/bin/bundler/plugins/XanixAssets.js +0 -51
- package/dist/bin/bundler/plugins/XanixCacheDeps-dep.d.ts +0 -2
- package/dist/bin/bundler/plugins/XanixCacheDeps-dep.js +0 -150
- package/dist/bin/bundler/plugins/XanixCacheDeps.d.ts +0 -2
- package/dist/bin/bundler/plugins/XanixCacheDeps.js +0 -150
- package/dist/bin/bundler/plugins/XanixDocument/index.js +0 -53
- package/dist/bin/bundler/plugins/XanixEntryFinder/finder.d.ts +0 -11
- package/dist/bin/bundler/plugins/XanixEntryFinder/finder.js +0 -149
- package/dist/bin/bundler/plugins/XanixEntryFinder/index.d.ts +0 -6
- package/dist/bin/bundler/plugins/XanixEntryFinder/index.js +0 -37
- package/dist/bin/bundler/plugins/XanixEntryFinder-dep/finder.d.ts +0 -11
- package/dist/bin/bundler/plugins/XanixEntryFinder-dep/finder.js +0 -149
- package/dist/bin/bundler/plugins/XanixEntryFinder-dep/index.d.ts +0 -6
- package/dist/bin/bundler/plugins/XanixEntryFinder-dep/index.js +0 -37
- package/dist/bin/bundler/plugins/XanixEnv.d.ts +0 -15
- package/dist/bin/bundler/plugins/XanixEnv.js +0 -44
- package/dist/bin/bundler/plugins/XanixPageTransform/index.d.ts +0 -2
- package/dist/bin/bundler/plugins/XanixPageTransform/index.js +0 -62
- package/dist/bin/bundler/plugins/XanixPageTransform/transformer copy.d.ts +0 -18
- package/dist/bin/bundler/plugins/XanixPageTransform/transformer copy.js +0 -414
- package/dist/bin/bundler/plugins/XanixPageTransform/transformer.d.ts +0 -23
- package/dist/bin/bundler/plugins/XanixPageTransform/transformer.js +0 -589
- package/dist/bin/bundler/plugins/XanixReactRefresh copy.d.ts +0 -2
- package/dist/bin/bundler/plugins/XanixReactRefresh copy.js +0 -121
- package/dist/bin/bundler/plugins/XanixReactRefresh.d.ts +0 -2
- package/dist/bin/bundler/plugins/XanixReactRefresh.js +0 -170
- package/dist/bin/bundler/plugins/XanixResolveCacheDeps/BuildClientCache.d.ts +0 -11
- package/dist/bin/bundler/plugins/XanixResolveCacheDeps/BuildClientCache.js +0 -129
- package/dist/bin/bundler/plugins/XanixResolveCacheDeps/index copy.d.ts +0 -15
- package/dist/bin/bundler/plugins/XanixResolveCacheDeps/index copy.js +0 -228
- package/dist/bin/bundler/plugins/XanixResolveCacheDeps/index.d.ts +0 -7
- package/dist/bin/bundler/plugins/XanixResolveCacheDeps/index.js +0 -166
- package/dist/bin/bundler/plugins/XanixResolveCacheDeps-dep/BuildClientCache.d.ts +0 -11
- package/dist/bin/bundler/plugins/XanixResolveCacheDeps-dep/BuildClientCache.js +0 -129
- package/dist/bin/bundler/plugins/XanixResolveCacheDeps-dep/index.d.ts +0 -5
- package/dist/bin/bundler/plugins/XanixResolveCacheDeps-dep/index.js +0 -26
- package/dist/bin/bundler/plugins/XanixResolver.d.ts +0 -11
- package/dist/bin/bundler/plugins/XanixResolver.js +0 -55
- package/dist/bin/bundler/plugins/XanixServerTransform.d.ts +0 -5
- package/dist/bin/bundler/plugins/XanixServerTransform.js +0 -207
- package/dist/bin/bundler/plugins/XanixTransform.d.ts +0 -3
- package/dist/bin/bundler/plugins/XanixTransform.js +0 -23
- package/dist/bin/bundler/plugins/XanixTsconfigAlias.d.ts +0 -19
- package/dist/bin/bundler/plugins/XanixTsconfigAlias.js +0 -197
- package/dist/bin/bundler/plugins/XanixUseServer.d.ts +0 -7
- package/dist/bin/bundler/plugins/XanixUseServer.js +0 -445
- package/dist/bin/bundler/plugins/plugins.d.ts +0 -9
- package/dist/bin/bundler/plugins/plugins.js +0 -37
- package/dist/bin/bundler/requireCache.d.ts +0 -3
- package/dist/bin/bundler/requireCache.js +0 -85
- package/dist/bin/bundler/server/plugins/ServerAction.d.ts +0 -3
- package/dist/bin/bundler/server/plugins/ServerAction.js +0 -9
- package/dist/bin/bundler/server/plugins/Transformer/ServerAction.d.ts +0 -11
- package/dist/bin/bundler/server/plugins/Transformer/ServerAction.js +0 -28
- package/dist/bin/bundler/server/plugins/Transformer/TransformExpress copy.d.ts +0 -11
- package/dist/bin/bundler/server/plugins/Transformer/TransformExpress copy.js +0 -22
- package/dist/bin/bundler/server/plugins/Transformer/TransformExpress.d.ts +0 -10
- package/dist/bin/bundler/server/plugins/Transformer/TransformExpress.js +0 -19
- package/dist/bin/bundler/server/plugins/Transformer/TransformReactContext.d.ts +0 -17
- package/dist/bin/bundler/server/plugins/Transformer/TransformReactContext.js +0 -101
- package/dist/bin/bundler/server/plugins/Transformer/TransformServerAction copy.d.ts +0 -14
- package/dist/bin/bundler/server/plugins/Transformer/TransformServerAction copy.js +0 -38
- package/dist/bin/bundler/server/types.d.ts +0 -5
- package/dist/bin/bundler/server/types.js +0 -1
- package/dist/bin/bundler/watchClient.d.ts +0 -12
- package/dist/bin/bundler/watchClient.js +0 -104
- package/dist/bin/bundler/watchServer.d.ts +0 -10
- package/dist/bin/bundler/watchServer.js +0 -139
- package/dist/bin/cli/dev/dev.d.ts +0 -2
- package/dist/bin/cli/dev/dev.js +0 -178
- package/dist/bin/cli/start/start.d.ts +0 -2
- package/dist/bin/cli/start/start.js +0 -27
- package/dist/bin/include/entry.d.ts +0 -2
- package/dist/bin/include/entry.js +0 -21
- package/dist/bin/plugins/XanixDocument/XanixDocument.d.ts +0 -2
- package/dist/bin/plugins/XanixDocument/XanixDocument.js +0 -50
- package/dist/bin/plugins/XanixDocument/index.d.ts +0 -2
- package/dist/bin/plugins/XanixDocument/index.js +0 -50
- package/dist/bin/plugins/XanixPageTransform-dep/index.d.ts +0 -2
- package/dist/bin/plugins/XanixPageTransform-dep/index.js +0 -62
- package/dist/bin/plugins/XanixPageTransform-dep/transformer.d.ts +0 -23
- package/dist/bin/plugins/XanixPageTransform-dep/transformer.js +0 -589
- package/dist/bin/plugins/XanixServerTransform.d.ts +0 -5
- package/dist/bin/plugins/XanixServerTransform.js +0 -207
- package/dist/bin/plugins/XanixUseServer.d.ts +0 -7
- package/dist/bin/plugins/XanixUseServer.js +0 -445
- package/dist/bin/plugins/plugins.d.ts +0 -8
- package/dist/bin/plugins/plugins.js +0 -31
- package/dist/components/Script.d.ts +0 -3
- package/dist/components/Script.js +0 -5
- package/dist/dev.d.ts +0 -1
- package/dist/dev.js +0 -25
- package/dist/react/createContext.d.ts +0 -3
- package/dist/react/createContext.js +0 -11
- package/dist/react/index.d.ts +0 -12
- package/dist/react/index.js +0 -3
- package/dist/server/express/Ruter.d.ts +0 -2
- package/dist/server/express/Ruter.js +0 -15
- package/dist/server/runtime/createServer.d.ts +0 -12
- package/dist/server/runtime/createServer.js +0 -62
- package/dist/server/runtime/index.d.ts +0 -3
- package/dist/server/runtime/index.js +0 -3
- package/dist/server/runtime/readManifest.d.ts +0 -14
- package/dist/server/runtime/readManifest.js +0 -9
- package/dist/server/runtime/xanixPage.d.ts +0 -11
- package/dist/server/runtime/xanixPage.js +0 -92
- /package/dist/bin/bundler/{plugins/XanixDocument/index.d.ts → client/plugins/XanixPage.d.ts} +0 -0
- /package/dist/bin/{cli/start/utils.d.ts → bundler/server/plugins/replacer/useServer.d.ts} +0 -0
- /package/dist/bin/{cli/start/utils.js → bundler/server/plugins/replacer/useServer.js} +0 -0
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import outdirs from "../../../outdirs.js";
|
|
2
|
-
const client = (entries, { isDev }) => {
|
|
3
|
-
const _entries = {};
|
|
4
|
-
for (const entry of entries) {
|
|
5
|
-
_entries[entry.name] = entry;
|
|
6
|
-
}
|
|
7
|
-
const opt = {
|
|
8
|
-
dir: outdirs.client,
|
|
9
|
-
format: "esm",
|
|
10
|
-
entryFileNames: (id) => {
|
|
11
|
-
const entry = _entries[id.name];
|
|
12
|
-
if (entry) {
|
|
13
|
-
return `${entry.id}.js`;
|
|
14
|
-
}
|
|
15
|
-
return `[name].js`;
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
if (isDev) {
|
|
19
|
-
opt.sourcemap = true;
|
|
20
|
-
opt.preserveModules = true;
|
|
21
|
-
opt.preserveModulesRoot = process.cwd();
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
opt.chunkFileNames = "chunks/[hash].js";
|
|
25
|
-
opt.assetFileNames = "assets/[name][extname]";
|
|
26
|
-
}
|
|
27
|
-
return opt;
|
|
28
|
-
};
|
|
29
|
-
const server = (opt) => {
|
|
30
|
-
const options = {
|
|
31
|
-
dir: outdirs.server,
|
|
32
|
-
format: "esm",
|
|
33
|
-
entryFileNames: "[name].js",
|
|
34
|
-
chunkFileNames: "chunks/[name].js",
|
|
35
|
-
assetFileNames: "assets/[name][extname]",
|
|
36
|
-
};
|
|
37
|
-
if (opt.isDev) {
|
|
38
|
-
options.sourcemap = true;
|
|
39
|
-
// options.preserveModules = true;
|
|
40
|
-
// options.preserveModulesRoot = process.cwd();
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
options.chunkFileNames = "chunks/[hash].js";
|
|
44
|
-
options.assetFileNames = "assets/[name][extname]";
|
|
45
|
-
}
|
|
46
|
-
return options;
|
|
47
|
-
};
|
|
48
|
-
const bundlerOutput = {
|
|
49
|
-
client,
|
|
50
|
-
server,
|
|
51
|
-
};
|
|
52
|
-
export default bundlerOutput;
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
import { rolldown } from "rolldown";
|
|
4
|
-
import loadEnv from "../include/loadEnv.js";
|
|
5
|
-
import { tsconfigPathsMatcher } from "../plugins/XanixTsconfigAlias.js";
|
|
6
|
-
import { builtinModules } from "module";
|
|
7
|
-
const nodeBuiltins = new Set(builtinModules);
|
|
8
|
-
function isNodeBuiltin(id) {
|
|
9
|
-
const normalized = id.startsWith("node:") ? id.slice(5) : id;
|
|
10
|
-
return nodeBuiltins.has(normalized);
|
|
11
|
-
}
|
|
12
|
-
const makeFilename = (id) => {
|
|
13
|
-
let root = process.cwd().replace(/\\/g, "/").replace(/\/+/g, "/");
|
|
14
|
-
id = id
|
|
15
|
-
.trim()
|
|
16
|
-
.replace(/\\/g, "/")
|
|
17
|
-
.replace(/\/+/g, "-")
|
|
18
|
-
.replace(`${root}/`, "")
|
|
19
|
-
.replace("node_modules/", "")
|
|
20
|
-
.toLowerCase()
|
|
21
|
-
.split("?")[0];
|
|
22
|
-
return id;
|
|
23
|
-
};
|
|
24
|
-
function isPackageImport(source) {
|
|
25
|
-
// Relative import
|
|
26
|
-
if (source.startsWith("./") || source.startsWith("../")) {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
// Absolute filesystem path
|
|
30
|
-
if (source.startsWith("/") || /^[A-Za-z]:[\\/]/.test(source)) {
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
// URL / virtual module
|
|
34
|
-
if (source.startsWith("node:") ||
|
|
35
|
-
source.includes(":") ||
|
|
36
|
-
source.startsWith("\0")) {
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
|
-
// Everything else is a bare package specifier
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
|
-
const writeManifest = async (cached) => {
|
|
43
|
-
const file = path.resolve("node_modules/xanix-cache/manifest.json");
|
|
44
|
-
let manifest = {};
|
|
45
|
-
for (const [key, value] of cached.entries()) {
|
|
46
|
-
manifest[key] = value;
|
|
47
|
-
}
|
|
48
|
-
await fs.promises.writeFile(file, JSON.stringify(manifest, null, 2));
|
|
49
|
-
};
|
|
50
|
-
const readManifest = async () => {
|
|
51
|
-
const file = path.resolve("node_modules/xanix-cache/manifest.json");
|
|
52
|
-
if (!fs.existsSync(file)) {
|
|
53
|
-
return new Map();
|
|
54
|
-
}
|
|
55
|
-
const content = await fs.promises.readFile(file, "utf-8");
|
|
56
|
-
const parsed = JSON.parse(content);
|
|
57
|
-
const map = new Map(Object.entries(parsed));
|
|
58
|
-
return map;
|
|
59
|
-
};
|
|
60
|
-
const externalResolver = () => {
|
|
61
|
-
let initialBuild = false;
|
|
62
|
-
const cache = new Map();
|
|
63
|
-
return {
|
|
64
|
-
name: "externalResolver",
|
|
65
|
-
async buildStart() {
|
|
66
|
-
if (initialBuild) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
initialBuild = true;
|
|
70
|
-
const cacheDir = path.resolve("node_modules/xanix-cache");
|
|
71
|
-
// delete cache directory if it exists
|
|
72
|
-
if (fs.existsSync(cacheDir)) {
|
|
73
|
-
fs.rmSync(cacheDir, { recursive: true, force: true });
|
|
74
|
-
}
|
|
75
|
-
if (!fs.existsSync(cacheDir)) {
|
|
76
|
-
fs.mkdirSync(cacheDir, { recursive: true });
|
|
77
|
-
fs.writeFileSync(path.join(cacheDir, "package.json"), JSON.stringify({ type: "module" }));
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
async resolveId(source, importer) {
|
|
81
|
-
if (!importer) {
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
84
|
-
if (source.startsWith("/xanix-cache")) {
|
|
85
|
-
return {
|
|
86
|
-
id: source,
|
|
87
|
-
external: true,
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
return null;
|
|
91
|
-
// if (importer.includes("node_modules")) {
|
|
92
|
-
// return null;
|
|
93
|
-
// }
|
|
94
|
-
// if (source.startsWith("xanix")) {
|
|
95
|
-
// return null;
|
|
96
|
-
// }
|
|
97
|
-
// if (!isPackageImport(source)) {
|
|
98
|
-
// return null;
|
|
99
|
-
// }
|
|
100
|
-
// const name = makeFilename(source);
|
|
101
|
-
// cache.set(source, name);
|
|
102
|
-
// return {
|
|
103
|
-
// id: `xanix-cache/${name}.js`,
|
|
104
|
-
// external: true,
|
|
105
|
-
// };
|
|
106
|
-
},
|
|
107
|
-
transform(code) {
|
|
108
|
-
let changed = false;
|
|
109
|
-
const transformed = code.replace(/import\s*\{([^}]+)\}\s*from\s*(['"])([^'"]+)\2\s*;?/g, (match, imports, quote, source) => {
|
|
110
|
-
if (source.startsWith("xanix")) {
|
|
111
|
-
return match;
|
|
112
|
-
}
|
|
113
|
-
if (!isPackageImport(source)) {
|
|
114
|
-
return match;
|
|
115
|
-
}
|
|
116
|
-
const cleanSource = source.split("?")[0];
|
|
117
|
-
const name = makeFilename(cleanSource);
|
|
118
|
-
cache.set(cleanSource, name);
|
|
119
|
-
changed = true;
|
|
120
|
-
const localName = `_${name.replace(/[^a-zA-Z0-9_$]/g, "_")}`;
|
|
121
|
-
const declarations = imports
|
|
122
|
-
.split(",")
|
|
123
|
-
.map((item) => {
|
|
124
|
-
const [imported, local] = item
|
|
125
|
-
.trim()
|
|
126
|
-
.split(/\s+as\s+/)
|
|
127
|
-
.map((x) => x.trim());
|
|
128
|
-
return local ? `${imported}: ${local}` : imported;
|
|
129
|
-
})
|
|
130
|
-
.join(", ");
|
|
131
|
-
return [
|
|
132
|
-
`import ${localName} from ${quote}/xanix-cache/${name}.js${quote};`,
|
|
133
|
-
`const { ${declarations} } = ${localName};`,
|
|
134
|
-
].join("\n");
|
|
135
|
-
});
|
|
136
|
-
if (!changed) {
|
|
137
|
-
return null;
|
|
138
|
-
}
|
|
139
|
-
return {
|
|
140
|
-
code: transformed,
|
|
141
|
-
map: null,
|
|
142
|
-
};
|
|
143
|
-
},
|
|
144
|
-
async generateBundle() {
|
|
145
|
-
let manifest = await readManifest();
|
|
146
|
-
let changed = false;
|
|
147
|
-
const input = {};
|
|
148
|
-
for (const [source, name] of cache.entries()) {
|
|
149
|
-
input[name] = source;
|
|
150
|
-
if (!manifest.has(source)) {
|
|
151
|
-
manifest.set(source, name);
|
|
152
|
-
changed = true;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
if (!changed) {
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
const build = await rolldown({
|
|
159
|
-
input,
|
|
160
|
-
treeshake: true,
|
|
161
|
-
platform: "node",
|
|
162
|
-
tsconfig: true,
|
|
163
|
-
checks: {
|
|
164
|
-
moduleLevelDirective: false,
|
|
165
|
-
},
|
|
166
|
-
resolve: {
|
|
167
|
-
extensions: [".mjs", ".js", ".jsx", ".json", ".ts", ".tsx"],
|
|
168
|
-
conditionNames: ["node", "import", "module", "default"],
|
|
169
|
-
},
|
|
170
|
-
transform: {
|
|
171
|
-
target: "node20",
|
|
172
|
-
jsx: {
|
|
173
|
-
runtime: "automatic",
|
|
174
|
-
},
|
|
175
|
-
define: await loadEnv({
|
|
176
|
-
mode: "development",
|
|
177
|
-
isClient: false,
|
|
178
|
-
}),
|
|
179
|
-
},
|
|
180
|
-
external(id) {
|
|
181
|
-
if (isNodeBuiltin(id)) {
|
|
182
|
-
return true;
|
|
183
|
-
}
|
|
184
|
-
if (id === "is-promise") {
|
|
185
|
-
return true;
|
|
186
|
-
}
|
|
187
|
-
if (id === "virtual:xanix-document" || tsconfigPathsMatcher(id)) {
|
|
188
|
-
return false;
|
|
189
|
-
}
|
|
190
|
-
return false;
|
|
191
|
-
},
|
|
192
|
-
});
|
|
193
|
-
await build.write({
|
|
194
|
-
dir: "node_modules/xanix-cache",
|
|
195
|
-
format: "es",
|
|
196
|
-
entryFileNames: "[name].js",
|
|
197
|
-
});
|
|
198
|
-
await build.close();
|
|
199
|
-
await writeManifest(manifest);
|
|
200
|
-
},
|
|
201
|
-
};
|
|
202
|
-
};
|
|
203
|
-
export default externalResolver;
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
import { rolldown } from "rolldown";
|
|
4
|
-
import loadEnv from "./config/loadEnv.js";
|
|
5
|
-
import { tsconfigPathsMatcher } from "./plugins/XanixTsconfigAlias.js";
|
|
6
|
-
import { builtinModules } from "module";
|
|
7
|
-
const nodeBuiltins = new Set(builtinModules);
|
|
8
|
-
function isNodeBuiltin(id) {
|
|
9
|
-
const normalized = id.startsWith("node:") ? id.slice(5) : id;
|
|
10
|
-
return nodeBuiltins.has(normalized);
|
|
11
|
-
}
|
|
12
|
-
const makeFilename = (id) => {
|
|
13
|
-
let root = process.cwd().replace(/\\/g, "/").replace(/\/+/g, "/");
|
|
14
|
-
id = id
|
|
15
|
-
.trim()
|
|
16
|
-
.replace(/\\/g, "/")
|
|
17
|
-
.replace(/\/+/g, "-")
|
|
18
|
-
.replace(`${root}/`, "")
|
|
19
|
-
.replace("node_modules/", "")
|
|
20
|
-
.toLowerCase()
|
|
21
|
-
.split("?")[0];
|
|
22
|
-
return id;
|
|
23
|
-
};
|
|
24
|
-
function isPackageImport(source) {
|
|
25
|
-
// Relative import
|
|
26
|
-
if (source.startsWith("./") || source.startsWith("../")) {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
// Absolute filesystem path
|
|
30
|
-
if (source.startsWith("/") || /^[A-Za-z]:[\\/]/.test(source)) {
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
// URL / virtual module
|
|
34
|
-
if (source.startsWith("node:") ||
|
|
35
|
-
source.includes(":") ||
|
|
36
|
-
source.startsWith("\0")) {
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
|
-
// Everything else is a bare package specifier
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
|
-
const writeManifest = async (cached) => {
|
|
43
|
-
const file = path.resolve("node_modules/xanix-cache/manifest.json");
|
|
44
|
-
let manifest = {};
|
|
45
|
-
for (const [key, value] of cached.entries()) {
|
|
46
|
-
manifest[key] = value;
|
|
47
|
-
}
|
|
48
|
-
await fs.promises.writeFile(file, JSON.stringify(manifest, null, 2));
|
|
49
|
-
};
|
|
50
|
-
const readManifest = async () => {
|
|
51
|
-
const file = path.resolve("node_modules/xanix-cache/manifest.json");
|
|
52
|
-
if (!fs.existsSync(file)) {
|
|
53
|
-
return new Map();
|
|
54
|
-
}
|
|
55
|
-
const content = await fs.promises.readFile(file, "utf-8");
|
|
56
|
-
const parsed = JSON.parse(content);
|
|
57
|
-
const map = new Map(Object.entries(parsed));
|
|
58
|
-
return map;
|
|
59
|
-
};
|
|
60
|
-
const externalResolver = () => {
|
|
61
|
-
let initialBuild = false;
|
|
62
|
-
const cache = new Map();
|
|
63
|
-
return {
|
|
64
|
-
name: "externalResolver",
|
|
65
|
-
async buildStart() {
|
|
66
|
-
if (initialBuild) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
initialBuild = true;
|
|
70
|
-
const cacheDir = path.resolve("node_modules/xanix-cache");
|
|
71
|
-
// delete cache directory if it exists
|
|
72
|
-
if (fs.existsSync(cacheDir)) {
|
|
73
|
-
fs.rmSync(cacheDir, { recursive: true, force: true });
|
|
74
|
-
}
|
|
75
|
-
if (!fs.existsSync(cacheDir)) {
|
|
76
|
-
fs.mkdirSync(cacheDir, { recursive: true });
|
|
77
|
-
fs.writeFileSync(path.join(cacheDir, "package.json"), JSON.stringify({ type: "module" }));
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
async resolveId(source, importer) {
|
|
81
|
-
if (!importer) {
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
84
|
-
if (source.startsWith("/xanix-cache")) {
|
|
85
|
-
return {
|
|
86
|
-
id: source,
|
|
87
|
-
external: true,
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
return null;
|
|
91
|
-
// if (importer.includes("node_modules")) {
|
|
92
|
-
// return null;
|
|
93
|
-
// }
|
|
94
|
-
// if (source.startsWith("xanix")) {
|
|
95
|
-
// return null;
|
|
96
|
-
// }
|
|
97
|
-
// if (!isPackageImport(source)) {
|
|
98
|
-
// return null;
|
|
99
|
-
// }
|
|
100
|
-
// const name = makeFilename(source);
|
|
101
|
-
// cache.set(source, name);
|
|
102
|
-
// return {
|
|
103
|
-
// id: `xanix-cache/${name}.js`,
|
|
104
|
-
// external: true,
|
|
105
|
-
// };
|
|
106
|
-
},
|
|
107
|
-
transform(code) {
|
|
108
|
-
let changed = false;
|
|
109
|
-
const transformed = code.replace(/import\s*\{([^}]+)\}\s*from\s*(['"])([^'"]+)\2\s*;?/g, (match, imports, quote, source) => {
|
|
110
|
-
if (source.startsWith("xanix")) {
|
|
111
|
-
return match;
|
|
112
|
-
}
|
|
113
|
-
if (!isPackageImport(source)) {
|
|
114
|
-
return match;
|
|
115
|
-
}
|
|
116
|
-
const cleanSource = source.split("?")[0];
|
|
117
|
-
const name = makeFilename(cleanSource);
|
|
118
|
-
cache.set(cleanSource, name);
|
|
119
|
-
changed = true;
|
|
120
|
-
const localName = `_${name.replace(/[^a-zA-Z0-9_$]/g, "_")}`;
|
|
121
|
-
const declarations = imports
|
|
122
|
-
.split(",")
|
|
123
|
-
.map((item) => {
|
|
124
|
-
const [imported, local] = item
|
|
125
|
-
.trim()
|
|
126
|
-
.split(/\s+as\s+/)
|
|
127
|
-
.map((x) => x.trim());
|
|
128
|
-
return local ? `${imported}: ${local}` : imported;
|
|
129
|
-
})
|
|
130
|
-
.join(", ");
|
|
131
|
-
return [
|
|
132
|
-
`import ${localName} from ${quote}/xanix-cache/${name}.js${quote};`,
|
|
133
|
-
`const { ${declarations} } = ${localName};`,
|
|
134
|
-
].join("\n");
|
|
135
|
-
});
|
|
136
|
-
if (!changed) {
|
|
137
|
-
return null;
|
|
138
|
-
}
|
|
139
|
-
return {
|
|
140
|
-
code: transformed,
|
|
141
|
-
map: null,
|
|
142
|
-
};
|
|
143
|
-
},
|
|
144
|
-
async generateBundle() {
|
|
145
|
-
let manifest = await readManifest();
|
|
146
|
-
let changed = false;
|
|
147
|
-
const input = {};
|
|
148
|
-
for (const [source, name] of cache.entries()) {
|
|
149
|
-
input[name] = source;
|
|
150
|
-
if (!manifest.has(source)) {
|
|
151
|
-
manifest.set(source, name);
|
|
152
|
-
changed = true;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
if (!changed) {
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
const build = await rolldown({
|
|
159
|
-
input,
|
|
160
|
-
treeshake: true,
|
|
161
|
-
platform: "node",
|
|
162
|
-
tsconfig: true,
|
|
163
|
-
checks: {
|
|
164
|
-
moduleLevelDirective: false,
|
|
165
|
-
},
|
|
166
|
-
resolve: {
|
|
167
|
-
extensions: [".mjs", ".js", ".jsx", ".json", ".ts", ".tsx"],
|
|
168
|
-
conditionNames: ["node", "import", "module", "default"],
|
|
169
|
-
},
|
|
170
|
-
transform: {
|
|
171
|
-
target: "node20",
|
|
172
|
-
jsx: {
|
|
173
|
-
runtime: "automatic",
|
|
174
|
-
},
|
|
175
|
-
define: await loadEnv({
|
|
176
|
-
mode: "development",
|
|
177
|
-
isClient: false,
|
|
178
|
-
}),
|
|
179
|
-
},
|
|
180
|
-
external(id) {
|
|
181
|
-
if (isNodeBuiltin(id)) {
|
|
182
|
-
return true;
|
|
183
|
-
}
|
|
184
|
-
if (id === "is-promise") {
|
|
185
|
-
return true;
|
|
186
|
-
}
|
|
187
|
-
if (id === "virtual:xanix-document" || tsconfigPathsMatcher(id)) {
|
|
188
|
-
return false;
|
|
189
|
-
}
|
|
190
|
-
return false;
|
|
191
|
-
},
|
|
192
|
-
});
|
|
193
|
-
await build.write({
|
|
194
|
-
dir: "node_modules/xanix-cache",
|
|
195
|
-
format: "es",
|
|
196
|
-
entryFileNames: "[name].js",
|
|
197
|
-
});
|
|
198
|
-
await build.close();
|
|
199
|
-
await writeManifest(manifest);
|
|
200
|
-
},
|
|
201
|
-
};
|
|
202
|
-
};
|
|
203
|
-
export default externalResolver;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
class TransformExpress {
|
|
2
|
-
constructor() {
|
|
3
|
-
this.replacements = [];
|
|
4
|
-
}
|
|
5
|
-
transform(node) {
|
|
6
|
-
if (node.type === "ImportDeclaration" && node.source.value === "express") {
|
|
7
|
-
this.replacements.push({
|
|
8
|
-
start: node.source.start + 1,
|
|
9
|
-
end: node.source.end - 1,
|
|
10
|
-
value: "xanix/express",
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
// check require express
|
|
14
|
-
if (node.type === "CallExpression" &&
|
|
15
|
-
node.callee.name === "require" &&
|
|
16
|
-
node.arguments.length === 1 &&
|
|
17
|
-
node.arguments[0].value === "express") {
|
|
18
|
-
this.replacements.push({
|
|
19
|
-
start: node.arguments[0].start + 1,
|
|
20
|
-
end: node.arguments[0].end - 1,
|
|
21
|
-
value: "xanix/express",
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
export default TransformExpress;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
type Name = string;
|
|
2
|
-
type Entry = {
|
|
3
|
-
name: string;
|
|
4
|
-
id: string;
|
|
5
|
-
source: string;
|
|
6
|
-
resolved: string;
|
|
7
|
-
};
|
|
8
|
-
declare class TransformPage {
|
|
9
|
-
_replacements: {
|
|
10
|
-
start: number;
|
|
11
|
-
end: number;
|
|
12
|
-
value: string;
|
|
13
|
-
}[];
|
|
14
|
-
imports: Map<Name, string>;
|
|
15
|
-
entries: Entry[];
|
|
16
|
-
private identifiers;
|
|
17
|
-
get replacements(): {
|
|
18
|
-
start: number;
|
|
19
|
-
end: number;
|
|
20
|
-
value: string;
|
|
21
|
-
}[];
|
|
22
|
-
uid(source: string): string;
|
|
23
|
-
transform(node: any): void;
|
|
24
|
-
}
|
|
25
|
-
export default TransformPage;
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import crypto from "node:crypto";
|
|
2
|
-
class TransformPage {
|
|
3
|
-
constructor() {
|
|
4
|
-
this._replacements = [];
|
|
5
|
-
this.imports = new Map();
|
|
6
|
-
this.entries = [];
|
|
7
|
-
this.identifiers = [];
|
|
8
|
-
}
|
|
9
|
-
get replacements() {
|
|
10
|
-
for (const identifier of this.identifiers) {
|
|
11
|
-
const source = this.imports.get(identifier.name);
|
|
12
|
-
if (source) {
|
|
13
|
-
const id = this.uid(source);
|
|
14
|
-
this.entries.push({
|
|
15
|
-
name: identifier.name,
|
|
16
|
-
id,
|
|
17
|
-
source,
|
|
18
|
-
resolved: "",
|
|
19
|
-
});
|
|
20
|
-
this._replacements.push({
|
|
21
|
-
start: identifier.placement,
|
|
22
|
-
end: identifier.placement,
|
|
23
|
-
value: ` __xpage={{ id: "${id}", name: "${identifier.name}" }} `,
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return this._replacements;
|
|
28
|
-
}
|
|
29
|
-
uid(source) {
|
|
30
|
-
return crypto
|
|
31
|
-
.createHash("sha256")
|
|
32
|
-
.update(source)
|
|
33
|
-
.digest("hex")
|
|
34
|
-
.slice(0, 12);
|
|
35
|
-
}
|
|
36
|
-
transform(node) {
|
|
37
|
-
/*
|
|
38
|
-
res.send(<Home />) to
|
|
39
|
-
res.send(__xpage({
|
|
40
|
-
id: uid,
|
|
41
|
-
component: Home,
|
|
42
|
-
props: {},
|
|
43
|
-
request: req,
|
|
44
|
-
response: res,
|
|
45
|
-
}))
|
|
46
|
-
*/
|
|
47
|
-
if (node.type === "CallExpression" &&
|
|
48
|
-
node.callee.property?.name === "send" &&
|
|
49
|
-
node.arguments.length === 1 &&
|
|
50
|
-
node.arguments[0].type === "JSXElement") {
|
|
51
|
-
const element = node.arguments[0].openingElement;
|
|
52
|
-
const ComponentName = element.name.name;
|
|
53
|
-
const attrs = element.attributes;
|
|
54
|
-
let end = attrs.length > 0 ? attrs[attrs.length - 1].end : element.name.end;
|
|
55
|
-
this.identifiers.push({
|
|
56
|
-
placement: end,
|
|
57
|
-
name: ComponentName,
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
// find static imports and add them to this.imports array
|
|
61
|
-
if (node.type === "ImportDeclaration" &&
|
|
62
|
-
node.specifiers.length > 0 &&
|
|
63
|
-
node.specifiers[0].type === "ImportDefaultSpecifier") {
|
|
64
|
-
const source = node.source.value;
|
|
65
|
-
const specifier = node.specifiers[0].local.name;
|
|
66
|
-
this.imports.set(specifier, source);
|
|
67
|
-
}
|
|
68
|
-
// find rfom require
|
|
69
|
-
if (node.type === "VariableDeclaration" &&
|
|
70
|
-
node.declarations.length === 1 &&
|
|
71
|
-
node.declarations[0].init?.type === "CallExpression" &&
|
|
72
|
-
node.declarations[0].init.callee.name === "require") {
|
|
73
|
-
const source = node.declarations[0].init.arguments[0].value;
|
|
74
|
-
const specifier = node.declarations[0].id.name;
|
|
75
|
-
this.imports.set(specifier, source);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
export default TransformPage;
|