@modern-js/app-tools 1.22.2 → 2.0.0-alpha.0
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/CHANGELOG.md +1383 -104
- package/bin/modern.js +13 -1
- package/dist/js/modern/analyze/Builder.js +39 -0
- package/dist/js/modern/analyze/constants.js +48 -15
- package/dist/js/modern/analyze/generateCode.js +286 -133
- package/dist/js/modern/analyze/getBundleEntry.js +39 -41
- package/dist/js/modern/analyze/getClientRoutes/getRoutes.js +220 -0
- package/dist/js/modern/analyze/getClientRoutes/getRoutesLegacy.js +216 -0
- package/dist/js/modern/analyze/getClientRoutes/index.js +6 -0
- package/dist/js/modern/analyze/getClientRoutes/utils.js +31 -0
- package/dist/js/modern/analyze/getFileSystemEntry.js +74 -39
- package/dist/js/modern/analyze/getHtmlTemplate.js +90 -57
- package/dist/js/modern/analyze/getServerRoutes.js +123 -140
- package/dist/js/modern/analyze/index.js +220 -133
- package/dist/js/modern/analyze/isDefaultExportFunction.js +30 -20
- package/dist/js/modern/analyze/makeLegalIdentifier.js +10 -13
- package/dist/js/modern/analyze/nestedRoutes.js +166 -0
- package/dist/js/modern/analyze/templates.js +289 -29
- package/dist/js/modern/analyze/utils.js +128 -58
- package/dist/js/modern/builder/builderPlugins/compatModern.js +233 -0
- package/dist/js/modern/builder/index.js +154 -0
- package/dist/js/modern/builder/loaders/routerLoader.js +17 -0
- package/dist/js/modern/builder/loaders/serverModuleLoader.js +7 -0
- package/dist/js/modern/builder/share.js +46 -0
- package/dist/js/modern/builder/webpackPlugins/htmlAsyncChunkPlugin.js +30 -0
- package/dist/js/modern/builder/webpackPlugins/htmlBottomTemplate.js +37 -0
- package/dist/js/modern/builder/webpackPlugins/routerPlugin.js +113 -0
- package/dist/js/modern/commands/build.js +75 -138
- package/dist/js/modern/commands/deploy.js +27 -4
- package/dist/js/modern/commands/dev.js +102 -66
- package/dist/js/modern/commands/index.js +1 -1
- package/dist/js/modern/commands/inspect.js +33 -64
- package/dist/js/modern/commands/serve.js +54 -0
- package/dist/js/modern/config/default.js +173 -0
- package/dist/js/modern/config/index.js +8 -0
- package/dist/js/modern/config/initial/createHtmlConfig.js +35 -0
- package/dist/js/modern/config/initial/createOutputConfig.js +68 -0
- package/dist/js/modern/config/initial/createSourceConfig.js +39 -0
- package/dist/js/modern/config/initial/createToolsConfig.js +42 -0
- package/dist/js/modern/config/initial/index.js +16 -0
- package/dist/js/modern/config/initial/inits.js +153 -0
- package/dist/js/modern/config/initial/transformNormalizedConfig.js +47 -0
- package/dist/js/modern/defineConfig.js +27 -0
- package/dist/js/modern/exports/server.js +4 -1
- package/dist/js/modern/hooks.js +37 -21
- package/dist/js/modern/index.js +185 -94
- package/dist/js/modern/initialize/index.js +120 -0
- package/dist/js/modern/locale/en.js +20 -22
- package/dist/js/modern/locale/index.js +6 -6
- package/dist/js/modern/locale/zh.js +21 -23
- package/dist/js/modern/schema/Schema.js +40 -0
- package/dist/js/modern/schema/index.js +88 -0
- package/dist/js/modern/schema/legacy.js +148 -0
- package/dist/js/modern/types/config/deploy.js +0 -0
- package/dist/js/modern/types/config/dev.js +0 -0
- package/dist/js/modern/types/config/experiments.js +0 -0
- package/dist/js/modern/types/config/html.js +0 -0
- package/dist/js/modern/types/config/index.js +1 -0
- package/dist/js/modern/types/config/output.js +0 -0
- package/dist/js/modern/types/config/performance.js +0 -0
- package/dist/js/modern/types/config/security.js +0 -0
- package/dist/js/modern/types/config/source.js +0 -0
- package/dist/js/modern/types/config/tools.js +0 -0
- package/dist/js/modern/types/hooks.js +0 -0
- package/dist/js/modern/types/index.js +3 -0
- package/dist/js/modern/types/legacyConfig/deploy.js +0 -0
- package/dist/js/modern/types/legacyConfig/dev.js +0 -0
- package/dist/js/modern/types/legacyConfig/index.js +0 -0
- package/dist/js/modern/types/legacyConfig/output.js +0 -0
- package/dist/js/modern/types/legacyConfig/source.js +0 -0
- package/dist/js/modern/types/legacyConfig/tools.js +0 -0
- package/dist/js/modern/utils/commands.js +13 -0
- package/dist/js/modern/utils/config.js +102 -52
- package/dist/js/modern/utils/createFileWatcher.js +115 -0
- package/dist/js/modern/utils/createServer.js +67 -10
- package/dist/js/modern/utils/getServerInternalPlugins.js +58 -0
- package/dist/js/modern/utils/getSpecifiedEntries.js +46 -25
- package/dist/js/modern/utils/language.js +6 -3
- package/dist/js/modern/utils/printInstructions.js +29 -9
- package/dist/js/modern/utils/restart.js +44 -0
- package/dist/js/modern/utils/routes.js +29 -14
- package/dist/js/node/analyze/Builder.js +64 -0
- package/dist/js/node/analyze/constants.js +86 -33
- package/dist/js/node/analyze/generateCode.js +305 -163
- package/dist/js/node/analyze/getBundleEntry.js +66 -58
- package/dist/js/node/analyze/getClientRoutes/getRoutes.js +242 -0
- package/dist/js/node/analyze/getClientRoutes/getRoutesLegacy.js +238 -0
- package/dist/js/node/analyze/getClientRoutes/index.js +30 -0
- package/dist/js/node/analyze/getClientRoutes/utils.js +58 -0
- package/dist/js/node/analyze/getFileSystemEntry.js +99 -58
- package/dist/js/node/analyze/getHtmlTemplate.js +121 -83
- package/dist/js/node/analyze/getServerRoutes.js +146 -160
- package/dist/js/node/analyze/index.js +243 -161
- package/dist/js/node/analyze/isDefaultExportFunction.js +59 -38
- package/dist/js/node/analyze/makeLegalIdentifier.js +31 -19
- package/dist/js/node/analyze/nestedRoutes.js +193 -0
- package/dist/js/node/analyze/templates.js +316 -43
- package/dist/js/node/analyze/utils.js +158 -78
- package/dist/js/node/builder/builderPlugins/compatModern.js +258 -0
- package/dist/js/node/builder/index.js +177 -0
- package/dist/js/node/builder/loaders/routerLoader.js +38 -0
- package/dist/js/node/builder/loaders/serverModuleLoader.js +28 -0
- package/dist/js/node/builder/share.js +75 -0
- package/dist/js/node/builder/webpackPlugins/htmlAsyncChunkPlugin.js +53 -0
- package/dist/js/node/builder/webpackPlugins/htmlBottomTemplate.js +60 -0
- package/dist/js/node/builder/webpackPlugins/routerPlugin.js +135 -0
- package/dist/js/node/commands/build.js +97 -159
- package/dist/js/node/commands/deploy.js +49 -12
- package/dist/js/node/commands/dev.js +121 -93
- package/dist/js/node/commands/index.js +19 -44
- package/dist/js/node/commands/inspect.js +56 -93
- package/dist/js/node/commands/serve.js +83 -0
- package/dist/js/node/config/default.js +195 -0
- package/dist/js/node/config/index.js +34 -0
- package/dist/js/node/config/initial/createHtmlConfig.js +58 -0
- package/dist/js/node/config/initial/createOutputConfig.js +91 -0
- package/dist/js/node/config/initial/createSourceConfig.js +62 -0
- package/dist/js/node/config/initial/createToolsConfig.js +65 -0
- package/dist/js/node/config/initial/index.js +41 -0
- package/dist/js/node/config/initial/inits.js +176 -0
- package/dist/js/node/config/initial/transformNormalizedConfig.js +70 -0
- package/dist/js/node/defineConfig.js +49 -0
- package/dist/js/node/exports/server.js +25 -11
- package/dist/js/node/hooks.js +53 -36
- package/dist/js/node/index.js +216 -128
- package/dist/js/node/initialize/index.js +135 -0
- package/dist/js/node/locale/en.js +40 -26
- package/dist/js/node/locale/index.js +31 -18
- package/dist/js/node/locale/zh.js +41 -27
- package/dist/js/node/schema/Schema.js +63 -0
- package/dist/js/node/schema/index.js +118 -0
- package/dist/js/node/schema/legacy.js +169 -0
- package/dist/js/node/types/config/deploy.js +15 -0
- package/dist/js/node/types/config/dev.js +15 -0
- package/dist/js/node/types/config/experiments.js +15 -0
- package/dist/js/node/types/config/html.js +15 -0
- package/dist/js/node/types/config/index.js +17 -0
- package/dist/js/node/types/config/output.js +15 -0
- package/dist/js/node/types/config/performance.js +15 -0
- package/dist/js/node/types/config/security.js +15 -0
- package/dist/js/node/types/config/source.js +15 -0
- package/dist/js/node/types/config/tools.js +15 -0
- package/dist/js/node/types/hooks.js +15 -0
- package/dist/js/node/types/index.js +19 -0
- package/dist/js/node/types/legacyConfig/deploy.js +15 -0
- package/dist/js/node/types/legacyConfig/dev.js +15 -0
- package/dist/js/node/types/legacyConfig/index.js +15 -0
- package/dist/js/node/types/legacyConfig/output.js +15 -0
- package/dist/js/node/types/legacyConfig/source.js +15 -0
- package/dist/js/node/types/legacyConfig/tools.js +15 -0
- package/dist/js/node/utils/commands.js +37 -0
- package/dist/js/node/utils/config.js +125 -75
- package/dist/js/node/utils/createFileWatcher.js +139 -0
- package/dist/js/node/utils/createServer.js +96 -25
- package/dist/js/node/utils/getServerInternalPlugins.js +79 -0
- package/dist/js/node/utils/getSpecifiedEntries.js +68 -34
- package/dist/js/node/utils/language.js +28 -10
- package/dist/js/node/utils/printInstructions.js +51 -19
- package/dist/js/node/utils/restart.js +67 -0
- package/dist/js/node/utils/routes.js +58 -24
- package/dist/js/node/utils/types.js +15 -0
- package/dist/js/treeshaking/analyze/Builder.js +199 -0
- package/dist/js/treeshaking/analyze/constants.js +37 -0
- package/dist/js/treeshaking/analyze/generateCode.js +615 -0
- package/dist/js/treeshaking/analyze/getBundleEntry.js +64 -0
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutes.js +233 -0
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutesLegacy.js +231 -0
- package/dist/js/treeshaking/analyze/getClientRoutes/index.js +3 -0
- package/dist/js/treeshaking/analyze/getClientRoutes/utils.js +23 -0
- package/dist/js/treeshaking/analyze/getFileSystemEntry.js +107 -0
- package/dist/js/treeshaking/analyze/getHtmlTemplate.js +302 -0
- package/dist/js/treeshaking/analyze/getServerRoutes.js +222 -0
- package/dist/js/treeshaking/analyze/index.js +589 -0
- package/dist/js/treeshaking/analyze/isDefaultExportFunction.js +47 -0
- package/dist/js/treeshaking/analyze/makeLegalIdentifier.js +13 -0
- package/dist/js/treeshaking/analyze/nestedRoutes.js +426 -0
- package/dist/js/treeshaking/analyze/templates.js +446 -0
- package/dist/js/treeshaking/analyze/utils.js +390 -0
- package/dist/js/treeshaking/builder/builderPlugins/compatModern.js +304 -0
- package/dist/js/treeshaking/builder/index.js +374 -0
- package/dist/js/treeshaking/builder/loaders/routerLoader.js +13 -0
- package/dist/js/treeshaking/builder/loaders/serverModuleLoader.js +5 -0
- package/dist/js/treeshaking/builder/share.js +40 -0
- package/dist/js/treeshaking/builder/webpackPlugins/htmlAsyncChunkPlugin.js +110 -0
- package/dist/js/treeshaking/builder/webpackPlugins/htmlBottomTemplate.js +72 -0
- package/dist/js/treeshaking/builder/webpackPlugins/routerPlugin.js +343 -0
- package/dist/js/treeshaking/commands/build.js +291 -0
- package/dist/js/treeshaking/commands/deploy.js +154 -0
- package/dist/js/treeshaking/commands/dev.js +319 -0
- package/dist/js/treeshaking/commands/index.js +3 -0
- package/dist/js/treeshaking/commands/inspect.js +149 -0
- package/dist/js/treeshaking/commands/serve.js +199 -0
- package/dist/js/treeshaking/config/default.js +208 -0
- package/dist/js/treeshaking/config/index.js +3 -0
- package/dist/js/treeshaking/config/initial/createHtmlConfig.js +19 -0
- package/dist/js/treeshaking/config/initial/createOutputConfig.js +41 -0
- package/dist/js/treeshaking/config/initial/createSourceConfig.js +42 -0
- package/dist/js/treeshaking/config/initial/createToolsConfig.js +23 -0
- package/dist/js/treeshaking/config/initial/index.js +12 -0
- package/dist/js/treeshaking/config/initial/inits.js +213 -0
- package/dist/js/treeshaking/config/initial/transformNormalizedConfig.js +35 -0
- package/dist/js/treeshaking/defineConfig.js +61 -0
- package/dist/js/treeshaking/exports/server.js +2 -0
- package/dist/js/treeshaking/hooks.js +31 -0
- package/dist/js/treeshaking/index.js +694 -0
- package/dist/js/treeshaking/initialize/index.js +300 -0
- package/dist/js/treeshaking/locale/en.js +35 -0
- package/dist/js/treeshaking/locale/index.js +9 -0
- package/dist/js/treeshaking/locale/zh.js +35 -0
- package/dist/js/treeshaking/schema/Schema.js +273 -0
- package/dist/js/treeshaking/schema/index.js +181 -0
- package/dist/js/treeshaking/schema/legacy.js +337 -0
- package/dist/js/treeshaking/types/config/deploy.js +1 -0
- package/dist/js/treeshaking/types/config/dev.js +1 -0
- package/dist/js/treeshaking/types/config/experiments.js +1 -0
- package/dist/js/treeshaking/types/config/html.js +1 -0
- package/dist/js/treeshaking/types/config/index.js +1 -0
- package/dist/js/treeshaking/types/config/output.js +1 -0
- package/dist/js/treeshaking/types/config/performance.js +1 -0
- package/dist/js/treeshaking/types/config/security.js +1 -0
- package/dist/js/treeshaking/types/config/source.js +1 -0
- package/dist/js/treeshaking/types/config/tools.js +1 -0
- package/dist/js/treeshaking/types/hooks.js +1 -0
- package/dist/js/treeshaking/types/index.js +3 -0
- package/dist/js/treeshaking/types/legacyConfig/deploy.js +1 -0
- package/dist/js/treeshaking/types/legacyConfig/dev.js +1 -0
- package/dist/js/treeshaking/types/legacyConfig/index.js +1 -0
- package/dist/js/treeshaking/types/legacyConfig/output.js +1 -0
- package/dist/js/treeshaking/types/legacyConfig/source.js +1 -0
- package/dist/js/treeshaking/types/legacyConfig/tools.js +1 -0
- package/dist/js/treeshaking/utils/commands.js +10 -0
- package/dist/js/treeshaking/utils/config.js +302 -0
- package/dist/js/treeshaking/utils/createFileWatcher.js +283 -0
- package/dist/js/treeshaking/utils/createServer.js +258 -0
- package/dist/js/treeshaking/utils/getServerInternalPlugins.js +210 -0
- package/dist/js/treeshaking/utils/getSpecifiedEntries.js +185 -0
- package/dist/js/treeshaking/utils/language.js +6 -0
- package/dist/js/treeshaking/utils/printInstructions.js +152 -0
- package/dist/js/treeshaking/utils/restart.js +187 -0
- package/dist/js/treeshaking/utils/routes.js +153 -0
- package/dist/js/treeshaking/utils/types.js +1 -0
- package/dist/types/analyze/Builder.d.ts +8 -0
- package/dist/types/analyze/constants.d.ts +13 -1
- package/dist/types/analyze/generateCode.d.ts +3 -2
- package/dist/types/analyze/getBundleEntry.d.ts +2 -2
- package/dist/types/analyze/{getClientRoutes.d.ts → getClientRoutes/getRoutes.d.ts} +2 -7
- package/dist/types/analyze/getClientRoutes/getRoutesLegacy.d.ts +15 -0
- package/dist/types/analyze/getClientRoutes/index.d.ts +2 -0
- package/dist/types/analyze/getClientRoutes/utils.d.ts +5 -0
- package/dist/types/analyze/getFileSystemEntry.d.ts +2 -2
- package/dist/types/analyze/getHtmlTemplate.d.ts +3 -3
- package/dist/types/analyze/getServerRoutes.d.ts +3 -2
- package/dist/types/analyze/index.d.ts +3 -40
- package/dist/types/analyze/nestedRoutes.d.ts +5 -0
- package/dist/types/analyze/templates.d.ts +24 -5
- package/dist/types/analyze/utils.d.ts +12 -2
- package/dist/types/builder/builderPlugins/compatModern.d.ts +14 -0
- package/dist/types/builder/index.d.ts +18 -0
- package/dist/types/builder/loaders/routerLoader.d.ts +3 -0
- package/dist/types/builder/loaders/serverModuleLoader.d.ts +3 -0
- package/dist/types/builder/share.d.ts +26 -0
- package/dist/types/builder/webpackPlugins/htmlAsyncChunkPlugin.d.ts +8 -0
- package/dist/types/builder/webpackPlugins/htmlBottomTemplate.d.ts +10 -0
- package/dist/types/builder/webpackPlugins/routerPlugin.d.ts +4 -0
- package/dist/types/commands/build.d.ts +2 -1
- package/dist/types/commands/deploy.d.ts +2 -1
- package/dist/types/commands/dev.d.ts +2 -1
- package/dist/types/commands/index.d.ts +1 -1
- package/dist/types/commands/inspect.d.ts +10 -6
- package/dist/types/commands/serve.d.ts +3 -0
- package/dist/types/config/default.d.ts +3 -0
- package/dist/types/config/index.d.ts +2 -0
- package/dist/types/config/initial/createHtmlConfig.d.ts +2 -0
- package/dist/types/config/initial/createOutputConfig.d.ts +2 -0
- package/dist/types/config/initial/createSourceConfig.d.ts +2 -0
- package/dist/types/config/initial/createToolsConfig.d.ts +2 -0
- package/dist/types/config/initial/index.d.ts +4 -0
- package/dist/types/config/initial/inits.d.ts +4 -0
- package/dist/types/config/initial/transformNormalizedConfig.d.ts +2 -0
- package/dist/types/defineConfig.d.ts +8 -0
- package/dist/types/hooks.d.ts +2 -37
- package/dist/types/index.d.ts +9 -3
- package/dist/types/initialize/index.d.ts +5 -0
- package/dist/types/locale/en.d.ts +1 -2
- package/dist/types/locale/index.d.ts +2 -4
- package/dist/types/locale/zh.d.ts +1 -2
- package/dist/types/schema/Schema.d.ts +14 -0
- package/dist/types/schema/index.d.ts +4 -0
- package/dist/types/schema/legacy.d.ts +3 -0
- package/dist/types/types/config/deploy.d.ts +9 -0
- package/dist/types/types/config/dev.d.ts +13 -0
- package/dist/types/types/config/experiments.d.ts +4 -0
- package/dist/types/types/config/html.d.ts +4 -0
- package/dist/types/types/config/index.d.ts +66 -0
- package/dist/types/types/config/output.d.ts +22 -0
- package/dist/types/types/config/performance.d.ts +4 -0
- package/dist/types/types/config/security.d.ts +4 -0
- package/dist/types/types/config/source.d.ts +24 -0
- package/dist/types/types/config/tools.d.ts +24 -0
- package/dist/types/types/hooks.d.ts +89 -0
- package/dist/types/types/index.d.ts +23 -0
- package/dist/types/types/legacyConfig/deploy.d.ts +8 -0
- package/dist/types/types/legacyConfig/dev.d.ts +13 -0
- package/dist/types/types/legacyConfig/index.d.ts +33 -0
- package/dist/types/types/legacyConfig/output.d.ts +51 -0
- package/dist/types/types/legacyConfig/source.d.ts +25 -0
- package/dist/types/types/legacyConfig/tools.d.ts +17 -0
- package/dist/types/utils/commands.d.ts +2 -0
- package/dist/types/utils/config.d.ts +2 -2
- package/dist/types/utils/createFileWatcher.d.ts +4 -0
- package/dist/types/utils/createServer.d.ts +9 -1
- package/dist/types/utils/getServerInternalPlugins.d.ts +2 -0
- package/dist/types/utils/printInstructions.d.ts +3 -2
- package/dist/types/utils/restart.d.ts +3 -0
- package/dist/types/utils/types.d.ts +2 -3
- package/lib/types.d.ts +1 -1
- package/package.json +37 -46
- package/dist/js/modern/analyze/getClientRoutes.js +0 -219
- package/dist/js/modern/commands/start.js +0 -31
- package/dist/js/modern/utils/createCompiler.js +0 -61
- package/dist/js/node/analyze/getClientRoutes.js +0 -241
- package/dist/js/node/commands/start.js +0 -47
- package/dist/js/node/utils/createCompiler.js +0 -81
- package/dist/types/commands/start.d.ts +0 -2
- package/dist/types/utils/createCompiler.d.ts +0 -13
|
@@ -0,0 +1,589 @@
|
|
|
1
|
+
function _arrayLikeToArray(arr, len) {
|
|
2
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
3
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
|
+
return arr2;
|
|
5
|
+
}
|
|
6
|
+
function _arrayWithHoles(arr) {
|
|
7
|
+
if (Array.isArray(arr)) return arr;
|
|
8
|
+
}
|
|
9
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
10
|
+
try {
|
|
11
|
+
var info = gen[key](arg);
|
|
12
|
+
var value = info.value;
|
|
13
|
+
} catch (error) {
|
|
14
|
+
reject(error);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (info.done) {
|
|
18
|
+
resolve(value);
|
|
19
|
+
} else {
|
|
20
|
+
Promise.resolve(value).then(_next, _throw);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function _asyncToGenerator(fn) {
|
|
24
|
+
return function() {
|
|
25
|
+
var self = this, args = arguments;
|
|
26
|
+
return new Promise(function(resolve, reject) {
|
|
27
|
+
var gen = fn.apply(self, args);
|
|
28
|
+
function _next(value) {
|
|
29
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
30
|
+
}
|
|
31
|
+
function _throw(err) {
|
|
32
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
33
|
+
}
|
|
34
|
+
_next(undefined);
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function _defineProperty(obj, key, value) {
|
|
39
|
+
if (key in obj) {
|
|
40
|
+
Object.defineProperty(obj, key, {
|
|
41
|
+
value: value,
|
|
42
|
+
enumerable: true,
|
|
43
|
+
configurable: true,
|
|
44
|
+
writable: true
|
|
45
|
+
});
|
|
46
|
+
} else {
|
|
47
|
+
obj[key] = value;
|
|
48
|
+
}
|
|
49
|
+
return obj;
|
|
50
|
+
}
|
|
51
|
+
function _iterableToArrayLimit(arr, i) {
|
|
52
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
53
|
+
if (_i == null) return;
|
|
54
|
+
var _arr = [];
|
|
55
|
+
var _n = true;
|
|
56
|
+
var _d = false;
|
|
57
|
+
var _s, _e;
|
|
58
|
+
try {
|
|
59
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
60
|
+
_arr.push(_s.value);
|
|
61
|
+
if (i && _arr.length === i) break;
|
|
62
|
+
}
|
|
63
|
+
} catch (err) {
|
|
64
|
+
_d = true;
|
|
65
|
+
_e = err;
|
|
66
|
+
} finally{
|
|
67
|
+
try {
|
|
68
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
69
|
+
} finally{
|
|
70
|
+
if (_d) throw _e;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return _arr;
|
|
74
|
+
}
|
|
75
|
+
function _nonIterableRest() {
|
|
76
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
77
|
+
}
|
|
78
|
+
function _objectSpread(target) {
|
|
79
|
+
for(var i = 1; i < arguments.length; i++){
|
|
80
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
81
|
+
var ownKeys = Object.keys(source);
|
|
82
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
83
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
84
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
87
|
+
ownKeys.forEach(function(key) {
|
|
88
|
+
_defineProperty(target, key, source[key]);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return target;
|
|
92
|
+
}
|
|
93
|
+
function ownKeys(object, enumerableOnly) {
|
|
94
|
+
var keys = Object.keys(object);
|
|
95
|
+
if (Object.getOwnPropertySymbols) {
|
|
96
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
97
|
+
if (enumerableOnly) {
|
|
98
|
+
symbols = symbols.filter(function(sym) {
|
|
99
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
keys.push.apply(keys, symbols);
|
|
103
|
+
}
|
|
104
|
+
return keys;
|
|
105
|
+
}
|
|
106
|
+
function _objectSpreadProps(target, source) {
|
|
107
|
+
source = source != null ? source : {};
|
|
108
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
109
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
110
|
+
} else {
|
|
111
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
112
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
return target;
|
|
116
|
+
}
|
|
117
|
+
function _slicedToArray(arr, i) {
|
|
118
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
119
|
+
}
|
|
120
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
121
|
+
if (!o) return;
|
|
122
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
123
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
124
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
125
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
126
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
127
|
+
}
|
|
128
|
+
var __generator = this && this.__generator || function(thisArg, body) {
|
|
129
|
+
var f, y, t, g, _ = {
|
|
130
|
+
label: 0,
|
|
131
|
+
sent: function() {
|
|
132
|
+
if (t[0] & 1) throw t[1];
|
|
133
|
+
return t[1];
|
|
134
|
+
},
|
|
135
|
+
trys: [],
|
|
136
|
+
ops: []
|
|
137
|
+
};
|
|
138
|
+
return g = {
|
|
139
|
+
next: verb(0),
|
|
140
|
+
"throw": verb(1),
|
|
141
|
+
"return": verb(2)
|
|
142
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
143
|
+
return this;
|
|
144
|
+
}), g;
|
|
145
|
+
function verb(n) {
|
|
146
|
+
return function(v) {
|
|
147
|
+
return step([
|
|
148
|
+
n,
|
|
149
|
+
v
|
|
150
|
+
]);
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
function step(op) {
|
|
154
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
155
|
+
while(_)try {
|
|
156
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
157
|
+
if (y = 0, t) op = [
|
|
158
|
+
op[0] & 2,
|
|
159
|
+
t.value
|
|
160
|
+
];
|
|
161
|
+
switch(op[0]){
|
|
162
|
+
case 0:
|
|
163
|
+
case 1:
|
|
164
|
+
t = op;
|
|
165
|
+
break;
|
|
166
|
+
case 4:
|
|
167
|
+
_.label++;
|
|
168
|
+
return {
|
|
169
|
+
value: op[1],
|
|
170
|
+
done: false
|
|
171
|
+
};
|
|
172
|
+
case 5:
|
|
173
|
+
_.label++;
|
|
174
|
+
y = op[1];
|
|
175
|
+
op = [
|
|
176
|
+
0
|
|
177
|
+
];
|
|
178
|
+
continue;
|
|
179
|
+
case 7:
|
|
180
|
+
op = _.ops.pop();
|
|
181
|
+
_.trys.pop();
|
|
182
|
+
continue;
|
|
183
|
+
default:
|
|
184
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
185
|
+
_ = 0;
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
189
|
+
_.label = op[1];
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
193
|
+
_.label = t[1];
|
|
194
|
+
t = op;
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
197
|
+
if (t && _.label < t[2]) {
|
|
198
|
+
_.label = t[2];
|
|
199
|
+
_.ops.push(op);
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
if (t[2]) _.ops.pop();
|
|
203
|
+
_.trys.pop();
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
op = body.call(thisArg, _);
|
|
207
|
+
} catch (e) {
|
|
208
|
+
op = [
|
|
209
|
+
6,
|
|
210
|
+
e
|
|
211
|
+
];
|
|
212
|
+
y = 0;
|
|
213
|
+
} finally{
|
|
214
|
+
f = t = 0;
|
|
215
|
+
}
|
|
216
|
+
if (op[0] & 5) throw op[1];
|
|
217
|
+
return {
|
|
218
|
+
value: op[0] ? op[1] : void 0,
|
|
219
|
+
done: true
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
import * as path from "path";
|
|
224
|
+
import { createDebugger, fs, isApiOnly } from "@modern-js/utils";
|
|
225
|
+
import { cloneDeep } from "@modern-js/utils/lodash";
|
|
226
|
+
import { createBuilderForModern } from "../builder";
|
|
227
|
+
import { printInstructions } from "../utils/printInstructions";
|
|
228
|
+
import { generateRoutes } from "../utils/routes";
|
|
229
|
+
import { emitResolvedConfig } from "../utils/config";
|
|
230
|
+
import { getCommand } from "../utils/commands";
|
|
231
|
+
import { initialNormalizedConfig } from "../config";
|
|
232
|
+
import { isNestedRouteComponent, isPageComponentFile } from "./utils";
|
|
233
|
+
import { loaderBuilder, serverLoaderBuilder } from "./Builder";
|
|
234
|
+
var debug = createDebugger("plugin-analyze");
|
|
235
|
+
var analyze_default = function() {
|
|
236
|
+
return {
|
|
237
|
+
name: "@modern-js/plugin-analyze",
|
|
238
|
+
setup: function(api) {
|
|
239
|
+
var pagesDir = [];
|
|
240
|
+
var nestedRouteEntries = [];
|
|
241
|
+
var originEntrypoints = [];
|
|
242
|
+
return {
|
|
243
|
+
prepare: function prepare() {
|
|
244
|
+
return _asyncToGenerator(function() {
|
|
245
|
+
var ref, appContext, resolvedConfig, hookRunners, apiOnly, ref1, routes2, ref2, getBundleEntry, getServerRoutes, generateCode, getHtmlTemplate, entrypoints, defaultChecked, initialRoutes, routes, htmlTemplates, command, buildCommands, normalizedConfig, builder;
|
|
246
|
+
return __generator(this, function(_state) {
|
|
247
|
+
switch(_state.label){
|
|
248
|
+
case 0:
|
|
249
|
+
appContext = api.useAppContext();
|
|
250
|
+
resolvedConfig = api.useResolvedConfigContext();
|
|
251
|
+
hookRunners = api.useHookRunners();
|
|
252
|
+
try {
|
|
253
|
+
fs.emptydirSync(appContext.internalDirectory);
|
|
254
|
+
} catch (e) {}
|
|
255
|
+
return [
|
|
256
|
+
4,
|
|
257
|
+
isApiOnly(appContext.appDirectory, (ref = resolvedConfig.source) === null || ref === void 0 ? void 0 : ref.entriesDir)
|
|
258
|
+
];
|
|
259
|
+
case 1:
|
|
260
|
+
apiOnly = _state.sent();
|
|
261
|
+
return [
|
|
262
|
+
4,
|
|
263
|
+
hookRunners.addRuntimeExports()
|
|
264
|
+
];
|
|
265
|
+
case 2:
|
|
266
|
+
_state.sent();
|
|
267
|
+
if (!apiOnly) return [
|
|
268
|
+
3,
|
|
269
|
+
4
|
|
270
|
+
];
|
|
271
|
+
return [
|
|
272
|
+
4,
|
|
273
|
+
hookRunners.modifyServerRoutes({
|
|
274
|
+
routes: []
|
|
275
|
+
})
|
|
276
|
+
];
|
|
277
|
+
case 3:
|
|
278
|
+
ref1 = _state.sent(), routes2 = ref1.routes;
|
|
279
|
+
debug("server routes: %o", routes2);
|
|
280
|
+
appContext = _objectSpreadProps(_objectSpread({}, appContext), {
|
|
281
|
+
apiOnly: apiOnly,
|
|
282
|
+
serverRoutes: routes2
|
|
283
|
+
});
|
|
284
|
+
api.setAppContext(appContext);
|
|
285
|
+
return [
|
|
286
|
+
2
|
|
287
|
+
];
|
|
288
|
+
case 4:
|
|
289
|
+
return [
|
|
290
|
+
4,
|
|
291
|
+
Promise.all([
|
|
292
|
+
import("./getBundleEntry"),
|
|
293
|
+
import("./getServerRoutes"),
|
|
294
|
+
import("./generateCode"),
|
|
295
|
+
import("./getHtmlTemplate")
|
|
296
|
+
])
|
|
297
|
+
];
|
|
298
|
+
case 5:
|
|
299
|
+
ref2 = _slicedToArray.apply(void 0, [
|
|
300
|
+
_state.sent(),
|
|
301
|
+
4
|
|
302
|
+
]), getBundleEntry = ref2[0].getBundleEntry, getServerRoutes = ref2[1].getServerRoutes, generateCode = ref2[2].generateCode, getHtmlTemplate = ref2[3].getHtmlTemplate;
|
|
303
|
+
entrypoints = getBundleEntry(appContext, resolvedConfig);
|
|
304
|
+
console.log("final entries", entrypoints);
|
|
305
|
+
defaultChecked = entrypoints.map(function(point) {
|
|
306
|
+
return point.entryName;
|
|
307
|
+
});
|
|
308
|
+
debug("entrypoints: %o", entrypoints);
|
|
309
|
+
initialRoutes = getServerRoutes(entrypoints, {
|
|
310
|
+
appContext: appContext,
|
|
311
|
+
config: resolvedConfig
|
|
312
|
+
});
|
|
313
|
+
return [
|
|
314
|
+
4,
|
|
315
|
+
hookRunners.modifyServerRoutes({
|
|
316
|
+
routes: initialRoutes
|
|
317
|
+
})
|
|
318
|
+
];
|
|
319
|
+
case 6:
|
|
320
|
+
routes = _state.sent().routes;
|
|
321
|
+
debug("server routes: %o", routes);
|
|
322
|
+
appContext = _objectSpreadProps(_objectSpread({}, appContext), {
|
|
323
|
+
entrypoints: entrypoints,
|
|
324
|
+
serverRoutes: routes
|
|
325
|
+
});
|
|
326
|
+
api.setAppContext(appContext);
|
|
327
|
+
nestedRouteEntries = entrypoints.map(function(point) {
|
|
328
|
+
return point.nestedRoutesEntry;
|
|
329
|
+
}).filter(Boolean);
|
|
330
|
+
pagesDir = entrypoints.map(function(point) {
|
|
331
|
+
return point.entry;
|
|
332
|
+
}).filter(Boolean).concat(nestedRouteEntries);
|
|
333
|
+
originEntrypoints = cloneDeep(entrypoints);
|
|
334
|
+
return [
|
|
335
|
+
4,
|
|
336
|
+
generateCode(appContext, resolvedConfig, entrypoints, api)
|
|
337
|
+
];
|
|
338
|
+
case 7:
|
|
339
|
+
_state.sent();
|
|
340
|
+
return [
|
|
341
|
+
4,
|
|
342
|
+
getHtmlTemplate(entrypoints, api, {
|
|
343
|
+
appContext: appContext,
|
|
344
|
+
config: resolvedConfig
|
|
345
|
+
})
|
|
346
|
+
];
|
|
347
|
+
case 8:
|
|
348
|
+
htmlTemplates = _state.sent();
|
|
349
|
+
debug("html templates: %o", htmlTemplates);
|
|
350
|
+
return [
|
|
351
|
+
4,
|
|
352
|
+
hookRunners.addDefineTypes()
|
|
353
|
+
];
|
|
354
|
+
case 9:
|
|
355
|
+
_state.sent();
|
|
356
|
+
debug("add Define Types");
|
|
357
|
+
appContext = _objectSpreadProps(_objectSpread({}, appContext), {
|
|
358
|
+
entrypoints: entrypoints,
|
|
359
|
+
checkedEntries: defaultChecked,
|
|
360
|
+
apiOnly: apiOnly,
|
|
361
|
+
serverRoutes: routes,
|
|
362
|
+
htmlTemplates: htmlTemplates
|
|
363
|
+
});
|
|
364
|
+
api.setAppContext(appContext);
|
|
365
|
+
command = getCommand();
|
|
366
|
+
buildCommands = [
|
|
367
|
+
"dev",
|
|
368
|
+
"start",
|
|
369
|
+
"build",
|
|
370
|
+
"inspect",
|
|
371
|
+
"deploy"
|
|
372
|
+
];
|
|
373
|
+
if (!buildCommands.includes(command)) return [
|
|
374
|
+
3,
|
|
375
|
+
11
|
|
376
|
+
];
|
|
377
|
+
normalizedConfig = api.useResolvedConfigContext();
|
|
378
|
+
return [
|
|
379
|
+
4,
|
|
380
|
+
createBuilderForModern({
|
|
381
|
+
normalizedConfig: normalizedConfig,
|
|
382
|
+
appContext: appContext,
|
|
383
|
+
compatPluginConfig: {
|
|
384
|
+
onBeforeBuild: function onBeforeBuild(param) {
|
|
385
|
+
var bundlerConfigs = param.bundlerConfigs;
|
|
386
|
+
return _asyncToGenerator(function() {
|
|
387
|
+
var hookRunners2;
|
|
388
|
+
return __generator(this, function(_state) {
|
|
389
|
+
switch(_state.label){
|
|
390
|
+
case 0:
|
|
391
|
+
hookRunners2 = api.useHookRunners();
|
|
392
|
+
return [
|
|
393
|
+
4,
|
|
394
|
+
generateRoutes(appContext)
|
|
395
|
+
];
|
|
396
|
+
case 1:
|
|
397
|
+
_state.sent();
|
|
398
|
+
return [
|
|
399
|
+
4,
|
|
400
|
+
hookRunners2.beforeBuild({
|
|
401
|
+
bundlerConfigs: bundlerConfigs
|
|
402
|
+
})
|
|
403
|
+
];
|
|
404
|
+
case 2:
|
|
405
|
+
_state.sent();
|
|
406
|
+
return [
|
|
407
|
+
2
|
|
408
|
+
];
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
})();
|
|
412
|
+
},
|
|
413
|
+
onAfterBuild: function onAfterBuild(param) {
|
|
414
|
+
var stats = param.stats;
|
|
415
|
+
return _asyncToGenerator(function() {
|
|
416
|
+
var hookRunners2;
|
|
417
|
+
return __generator(this, function(_state) {
|
|
418
|
+
switch(_state.label){
|
|
419
|
+
case 0:
|
|
420
|
+
hookRunners2 = api.useHookRunners();
|
|
421
|
+
return [
|
|
422
|
+
4,
|
|
423
|
+
hookRunners2.afterBuild({
|
|
424
|
+
stats: stats
|
|
425
|
+
})
|
|
426
|
+
];
|
|
427
|
+
case 1:
|
|
428
|
+
_state.sent();
|
|
429
|
+
return [
|
|
430
|
+
4,
|
|
431
|
+
emitResolvedConfig(appContext.appDirectory, normalizedConfig)
|
|
432
|
+
];
|
|
433
|
+
case 2:
|
|
434
|
+
_state.sent();
|
|
435
|
+
return [
|
|
436
|
+
2
|
|
437
|
+
];
|
|
438
|
+
}
|
|
439
|
+
});
|
|
440
|
+
})();
|
|
441
|
+
},
|
|
442
|
+
onDevCompileDone: function onDevCompileDone(param) {
|
|
443
|
+
var isFirstCompile = param.isFirstCompile;
|
|
444
|
+
return _asyncToGenerator(function() {
|
|
445
|
+
var hookRunners2;
|
|
446
|
+
return __generator(this, function(_state) {
|
|
447
|
+
hookRunners2 = api.useHookRunners();
|
|
448
|
+
if (process.stdout.isTTY || isFirstCompile) {
|
|
449
|
+
hookRunners2.afterDev();
|
|
450
|
+
if (isFirstCompile) {
|
|
451
|
+
printInstructions(hookRunners2, appContext, normalizedConfig);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
return [
|
|
455
|
+
2
|
|
456
|
+
];
|
|
457
|
+
});
|
|
458
|
+
})();
|
|
459
|
+
},
|
|
460
|
+
onBeforeCreateCompiler: function onBeforeCreateCompiler(param) {
|
|
461
|
+
var bundlerConfigs = param.bundlerConfigs;
|
|
462
|
+
return _asyncToGenerator(function() {
|
|
463
|
+
var hookRunners2;
|
|
464
|
+
return __generator(this, function(_state) {
|
|
465
|
+
switch(_state.label){
|
|
466
|
+
case 0:
|
|
467
|
+
hookRunners2 = api.useHookRunners();
|
|
468
|
+
return [
|
|
469
|
+
4,
|
|
470
|
+
hookRunners2.beforeCreateCompiler({
|
|
471
|
+
bundlerConfigs: bundlerConfigs
|
|
472
|
+
})
|
|
473
|
+
];
|
|
474
|
+
case 1:
|
|
475
|
+
_state.sent();
|
|
476
|
+
return [
|
|
477
|
+
2
|
|
478
|
+
];
|
|
479
|
+
}
|
|
480
|
+
});
|
|
481
|
+
})();
|
|
482
|
+
},
|
|
483
|
+
onAfterCreateCompiler: function onAfterCreateCompiler(param) {
|
|
484
|
+
var compiler = param.compiler;
|
|
485
|
+
return _asyncToGenerator(function() {
|
|
486
|
+
var hookRunners2;
|
|
487
|
+
return __generator(this, function(_state) {
|
|
488
|
+
switch(_state.label){
|
|
489
|
+
case 0:
|
|
490
|
+
hookRunners2 = api.useHookRunners();
|
|
491
|
+
return [
|
|
492
|
+
4,
|
|
493
|
+
hookRunners2.afterCreateCompiler({
|
|
494
|
+
compiler: compiler
|
|
495
|
+
})
|
|
496
|
+
];
|
|
497
|
+
case 1:
|
|
498
|
+
_state.sent();
|
|
499
|
+
return [
|
|
500
|
+
2
|
|
501
|
+
];
|
|
502
|
+
}
|
|
503
|
+
});
|
|
504
|
+
})();
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
})
|
|
508
|
+
];
|
|
509
|
+
case 10:
|
|
510
|
+
builder = _state.sent();
|
|
511
|
+
builder.addPlugins(resolvedConfig.builderPlugins);
|
|
512
|
+
appContext = _objectSpreadProps(_objectSpread({}, appContext), {
|
|
513
|
+
builder: builder
|
|
514
|
+
});
|
|
515
|
+
api.setAppContext(appContext);
|
|
516
|
+
_state.label = 11;
|
|
517
|
+
case 11:
|
|
518
|
+
return [
|
|
519
|
+
2
|
|
520
|
+
];
|
|
521
|
+
}
|
|
522
|
+
});
|
|
523
|
+
})();
|
|
524
|
+
},
|
|
525
|
+
watchFiles: function watchFiles() {
|
|
526
|
+
return pagesDir;
|
|
527
|
+
},
|
|
528
|
+
resolvedConfig: function resolvedConfig(param) {
|
|
529
|
+
var resolved = param.resolved;
|
|
530
|
+
var appContext = api.useAppContext();
|
|
531
|
+
var config = initialNormalizedConfig(resolved, appContext);
|
|
532
|
+
return {
|
|
533
|
+
resolved: config
|
|
534
|
+
};
|
|
535
|
+
},
|
|
536
|
+
beforeRestart: function beforeRestart() {
|
|
537
|
+
return _asyncToGenerator(function() {
|
|
538
|
+
return __generator(this, function(_state) {
|
|
539
|
+
serverLoaderBuilder.stop();
|
|
540
|
+
loaderBuilder.stop();
|
|
541
|
+
return [
|
|
542
|
+
2
|
|
543
|
+
];
|
|
544
|
+
});
|
|
545
|
+
})();
|
|
546
|
+
},
|
|
547
|
+
fileChange: function fileChange(e) {
|
|
548
|
+
return _asyncToGenerator(function() {
|
|
549
|
+
var appContext, appDirectory, filename, eventType, isPageFile, absoluteFilePath, isRouteComponent, resolvedConfig, generateCode, entrypoints;
|
|
550
|
+
return __generator(this, function(_state) {
|
|
551
|
+
switch(_state.label){
|
|
552
|
+
case 0:
|
|
553
|
+
appContext = api.useAppContext();
|
|
554
|
+
appDirectory = appContext.appDirectory;
|
|
555
|
+
filename = e.filename, eventType = e.eventType;
|
|
556
|
+
isPageFile = function(name) {
|
|
557
|
+
return pagesDir.some(function(pageDir) {
|
|
558
|
+
return name.includes(pageDir);
|
|
559
|
+
});
|
|
560
|
+
};
|
|
561
|
+
absoluteFilePath = path.resolve(appDirectory, filename);
|
|
562
|
+
isRouteComponent = isPageFile(absoluteFilePath) && isPageComponentFile(absoluteFilePath);
|
|
563
|
+
if (!(isRouteComponent && (eventType === "add" || eventType === "unlink") || isNestedRouteComponent(nestedRouteEntries, absoluteFilePath) && eventType === "change")) return [
|
|
564
|
+
3,
|
|
565
|
+
2
|
|
566
|
+
];
|
|
567
|
+
resolvedConfig = api.useResolvedConfigContext();
|
|
568
|
+
return [
|
|
569
|
+
4,
|
|
570
|
+
import("./generateCode")
|
|
571
|
+
];
|
|
572
|
+
case 1:
|
|
573
|
+
generateCode = _state.sent().generateCode;
|
|
574
|
+
entrypoints = cloneDeep(originEntrypoints);
|
|
575
|
+
generateCode(appContext, resolvedConfig, entrypoints, api);
|
|
576
|
+
_state.label = 2;
|
|
577
|
+
case 2:
|
|
578
|
+
return [
|
|
579
|
+
2
|
|
580
|
+
];
|
|
581
|
+
}
|
|
582
|
+
});
|
|
583
|
+
})();
|
|
584
|
+
}
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
};
|
|
588
|
+
};
|
|
589
|
+
export { analyze_default as default };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import { parse } from "@babel/parser";
|
|
3
|
+
import traverse from "@babel/traverse";
|
|
4
|
+
import * as t from "@babel/types";
|
|
5
|
+
var isFunction = function(node) {
|
|
6
|
+
return t.isFunctionDeclaration(node) || t.isFunctionExpression(node) || t.isArrowFunctionExpression(node);
|
|
7
|
+
};
|
|
8
|
+
var isDefaultExportFunction = function(file) {
|
|
9
|
+
if (!file || !fs.existsSync(file)) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
var ast = parse(fs.readFileSync(file, "utf8"), {
|
|
13
|
+
sourceType: "unambiguous",
|
|
14
|
+
plugins: [
|
|
15
|
+
"jsx",
|
|
16
|
+
"typescript",
|
|
17
|
+
"classProperties",
|
|
18
|
+
"dynamicImport",
|
|
19
|
+
"exportDefaultFrom",
|
|
20
|
+
"exportNamespaceFrom",
|
|
21
|
+
"decorators-legacy",
|
|
22
|
+
"functionBind",
|
|
23
|
+
"classPrivateMethods",
|
|
24
|
+
[
|
|
25
|
+
"pipelineOperator",
|
|
26
|
+
{
|
|
27
|
+
proposal: "minimal"
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
"optionalChaining",
|
|
31
|
+
"optionalCatchBinding",
|
|
32
|
+
"objectRestSpread",
|
|
33
|
+
"numericSeparator"
|
|
34
|
+
]
|
|
35
|
+
});
|
|
36
|
+
var isExportFunction = false;
|
|
37
|
+
traverse(ast, {
|
|
38
|
+
ExportDefaultDeclaration: function(path) {
|
|
39
|
+
var declaration = path.node.declaration;
|
|
40
|
+
if (isFunction(declaration)) {
|
|
41
|
+
isExportFunction = true;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
return isExportFunction;
|
|
46
|
+
};
|
|
47
|
+
export { isDefaultExportFunction };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
var reservedWords = "break case class catch const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield enum await implements package protected static interface private public";
|
|
2
|
+
var builtins = "arguments Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError Number Math Date String RegExp Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array Map Set WeakMap WeakSet SIMD ArrayBuffer DataView JSON Promise Generator GeneratorFunction Reflect Proxy Intl";
|
|
3
|
+
var forbidList = new Set("".concat(reservedWords, " ").concat(builtins).split(" "));
|
|
4
|
+
function makeLegalIdentifier(str) {
|
|
5
|
+
var identifier = str.replace(/-(\w)/g, function(_, letter) {
|
|
6
|
+
return letter.toUpperCase();
|
|
7
|
+
}).replace(/[^$_a-zA-Z0-9]/g, "_");
|
|
8
|
+
if (/\d/.test(identifier[0]) || forbidList.has(identifier)) {
|
|
9
|
+
return "_".concat(identifier);
|
|
10
|
+
}
|
|
11
|
+
return identifier || "_";
|
|
12
|
+
}
|
|
13
|
+
export { makeLegalIdentifier };
|