@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,15 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
var legacyConfig_exports = {};
|
|
15
|
+
module.exports = __toCommonJS(legacyConfig_exports);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
var output_exports = {};
|
|
15
|
+
module.exports = __toCommonJS(output_exports);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
var source_exports = {};
|
|
15
|
+
module.exports = __toCommonJS(source_exports);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
var tools_exports = {};
|
|
15
|
+
module.exports = __toCommonJS(tools_exports);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var commands_exports = {};
|
|
19
|
+
__export(commands_exports, {
|
|
20
|
+
getCommand: () => getCommand,
|
|
21
|
+
isDevCommand: () => isDevCommand
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(commands_exports);
|
|
24
|
+
const getCommand = () => {
|
|
25
|
+
const args = process.argv.slice(2);
|
|
26
|
+
const command = args[0];
|
|
27
|
+
return command;
|
|
28
|
+
};
|
|
29
|
+
const isDevCommand = () => {
|
|
30
|
+
const command = getCommand();
|
|
31
|
+
return command === "dev" || command === "start";
|
|
32
|
+
};
|
|
33
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
+
0 && (module.exports = {
|
|
35
|
+
getCommand,
|
|
36
|
+
isDevCommand
|
|
37
|
+
});
|
|
@@ -1,103 +1,153 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __export = (target, all) => {
|
|
25
|
+
for (var name in all)
|
|
26
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
27
|
+
};
|
|
28
|
+
var __copyProps = (to, from, except, desc) => {
|
|
29
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
30
|
+
for (let key of __getOwnPropNames(from))
|
|
31
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
32
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
33
|
+
}
|
|
34
|
+
return to;
|
|
35
|
+
};
|
|
36
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
37
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
38
|
+
mod
|
|
39
|
+
));
|
|
40
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
41
|
+
var __async = (__this, __arguments, generator) => {
|
|
42
|
+
return new Promise((resolve, reject) => {
|
|
43
|
+
var fulfilled = (value) => {
|
|
44
|
+
try {
|
|
45
|
+
step(generator.next(value));
|
|
46
|
+
} catch (e) {
|
|
47
|
+
reject(e);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
var rejected = (value) => {
|
|
51
|
+
try {
|
|
52
|
+
step(generator.throw(value));
|
|
53
|
+
} catch (e) {
|
|
54
|
+
reject(e);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
58
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
var config_exports = {};
|
|
62
|
+
__export(config_exports, {
|
|
63
|
+
buildServerConfig: () => buildServerConfig,
|
|
64
|
+
defineServerConfig: () => defineServerConfig,
|
|
65
|
+
emitResolvedConfig: () => emitResolvedConfig,
|
|
66
|
+
safeReplacer: () => safeReplacer
|
|
5
67
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _utils = require("@modern-js/utils");
|
|
13
|
-
|
|
14
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
|
-
|
|
16
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
|
-
|
|
18
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
19
|
-
|
|
20
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
21
|
-
|
|
22
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
23
|
-
|
|
24
|
-
const defineServerConfig = config => config;
|
|
25
|
-
|
|
26
|
-
exports.defineServerConfig = defineServerConfig;
|
|
27
|
-
|
|
28
|
-
const buildServerConfig = async ({
|
|
68
|
+
module.exports = __toCommonJS(config_exports);
|
|
69
|
+
var path = __toESM(require("path"));
|
|
70
|
+
var import_node_bundle_require = require("@modern-js/node-bundle-require");
|
|
71
|
+
var import_utils = require("@modern-js/utils");
|
|
72
|
+
const defineServerConfig = (config) => config;
|
|
73
|
+
const buildServerConfig = (_0) => __async(void 0, [_0], function* ({
|
|
29
74
|
appDirectory,
|
|
30
75
|
distDirectory,
|
|
31
76
|
configFile,
|
|
32
77
|
options
|
|
33
|
-
})
|
|
34
|
-
const configFilePath =
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
78
|
+
}) {
|
|
79
|
+
const configFilePath = yield (0, import_utils.getServerConfig)(appDirectory, configFile);
|
|
80
|
+
const getOutputFile = (filepath) => __async(void 0, null, function* () {
|
|
81
|
+
return path.resolve(
|
|
82
|
+
distDirectory,
|
|
83
|
+
`${filepath.replace(
|
|
84
|
+
new RegExp(import_utils.CONFIG_FILE_EXTENSIONS.join("|")),
|
|
85
|
+
""
|
|
86
|
+
)}.js`
|
|
87
|
+
);
|
|
88
|
+
});
|
|
38
89
|
if (configFilePath) {
|
|
39
|
-
const configHelperFilePath = path.normalize(
|
|
90
|
+
const configHelperFilePath = path.normalize(
|
|
91
|
+
path.join(distDirectory, "./config-helper.js")
|
|
92
|
+
);
|
|
40
93
|
const helperCode = `
|
|
41
94
|
export const defineConfig = (config) => config;
|
|
42
95
|
`;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
96
|
+
yield import_utils.fs.ensureDir(distDirectory);
|
|
97
|
+
yield import_utils.fs.writeFile(configHelperFilePath, helperCode);
|
|
98
|
+
yield (0, import_node_bundle_require.bundle)(configFilePath, __spreadProps(__spreadValues({}, options), {
|
|
46
99
|
getOutputFile,
|
|
47
|
-
esbuildPlugins: [
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
100
|
+
esbuildPlugins: [
|
|
101
|
+
{
|
|
102
|
+
name: "native-build-config",
|
|
103
|
+
setup(ctx) {
|
|
104
|
+
ctx.onResolve(
|
|
105
|
+
{
|
|
106
|
+
filter: /app-tools\/server/
|
|
107
|
+
},
|
|
108
|
+
() => {
|
|
109
|
+
return {
|
|
110
|
+
path: configHelperFilePath
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
);
|
|
114
|
+
}
|
|
58
115
|
}
|
|
59
|
-
|
|
60
|
-
}]
|
|
116
|
+
]
|
|
61
117
|
}));
|
|
62
118
|
}
|
|
63
|
-
};
|
|
64
|
-
/**
|
|
65
|
-
*
|
|
66
|
-
* 处理循环引用的 replacer
|
|
67
|
-
*/
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
exports.buildServerConfig = buildServerConfig;
|
|
71
|
-
|
|
119
|
+
});
|
|
72
120
|
const safeReplacer = () => {
|
|
73
121
|
const cache = [];
|
|
74
122
|
const keyCache = [];
|
|
75
|
-
return function
|
|
76
|
-
if (typeof value ===
|
|
123
|
+
return function(key, value) {
|
|
124
|
+
if (typeof value === "object" && value !== null) {
|
|
77
125
|
const index = cache.indexOf(value);
|
|
78
|
-
|
|
79
126
|
if (index !== -1) {
|
|
80
127
|
return `[Circular ${keyCache[index]}]`;
|
|
81
128
|
}
|
|
82
|
-
|
|
83
129
|
cache.push(value);
|
|
84
|
-
keyCache.push(key ||
|
|
130
|
+
keyCache.push(key || "root");
|
|
85
131
|
}
|
|
86
|
-
|
|
87
132
|
return value;
|
|
88
133
|
};
|
|
89
134
|
};
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
135
|
+
const emitResolvedConfig = (appDirectory, resolvedConfig) => __async(void 0, null, function* () {
|
|
136
|
+
var _a;
|
|
137
|
+
const outputPath = path.join(
|
|
138
|
+
appDirectory,
|
|
139
|
+
((_a = resolvedConfig.output.distPath) == null ? void 0 : _a.root) || "./dist",
|
|
140
|
+
import_utils.OUTPUT_CONFIG_FILE
|
|
141
|
+
);
|
|
142
|
+
yield import_utils.fs.writeJSON(outputPath, resolvedConfig, {
|
|
98
143
|
spaces: 2,
|
|
99
144
|
replacer: safeReplacer()
|
|
100
145
|
});
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
exports
|
|
146
|
+
});
|
|
147
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
148
|
+
0 && (module.exports = {
|
|
149
|
+
buildServerConfig,
|
|
150
|
+
defineServerConfig,
|
|
151
|
+
emitResolvedConfig,
|
|
152
|
+
safeReplacer
|
|
153
|
+
});
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var __async = (__this, __arguments, generator) => {
|
|
25
|
+
return new Promise((resolve, reject) => {
|
|
26
|
+
var fulfilled = (value) => {
|
|
27
|
+
try {
|
|
28
|
+
step(generator.next(value));
|
|
29
|
+
} catch (e) {
|
|
30
|
+
reject(e);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
var rejected = (value) => {
|
|
34
|
+
try {
|
|
35
|
+
step(generator.throw(value));
|
|
36
|
+
} catch (e) {
|
|
37
|
+
reject(e);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
41
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var createFileWatcher_exports = {};
|
|
45
|
+
__export(createFileWatcher_exports, {
|
|
46
|
+
addServerConfigToDeps: () => addServerConfigToDeps,
|
|
47
|
+
createFileWatcher: () => createFileWatcher
|
|
48
|
+
});
|
|
49
|
+
module.exports = __toCommonJS(createFileWatcher_exports);
|
|
50
|
+
var import_crypto = __toESM(require("crypto"));
|
|
51
|
+
var import_fs = __toESM(require("fs"));
|
|
52
|
+
var import_path = __toESM(require("path"));
|
|
53
|
+
var import_utils = require("@modern-js/utils");
|
|
54
|
+
const getPackageConfig = (appDirectory, packageJsonConfig) => {
|
|
55
|
+
const PACKAGE_JSON_CONFIG_NAME = "modernConfig";
|
|
56
|
+
const json = JSON.parse(
|
|
57
|
+
import_fs.default.readFileSync(import_path.default.resolve(appDirectory, "./package.json"), "utf8")
|
|
58
|
+
);
|
|
59
|
+
return json[packageJsonConfig != null ? packageJsonConfig : PACKAGE_JSON_CONFIG_NAME];
|
|
60
|
+
};
|
|
61
|
+
const addServerConfigToDeps = (dependencies, appDirectory, serverConfigFile) => __async(void 0, null, function* () {
|
|
62
|
+
const serverConfig = yield (0, import_utils.getServerConfig)(appDirectory, serverConfigFile);
|
|
63
|
+
if (serverConfig) {
|
|
64
|
+
dependencies.push(serverConfig);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
const debug = (0, import_utils.createDebugger)("watch-files");
|
|
68
|
+
const md5 = (data) => import_crypto.default.createHash("md5").update(data).digest("hex");
|
|
69
|
+
const hashMap = /* @__PURE__ */ new Map();
|
|
70
|
+
const createFileWatcher = (appContext, configDir, hooksRunner) => __async(void 0, null, function* () {
|
|
71
|
+
if ((0, import_utils.isDev)() || (0, import_utils.isTest)()) {
|
|
72
|
+
const { appDirectory, configFile } = appContext;
|
|
73
|
+
const extraFiles = yield hooksRunner.watchFiles();
|
|
74
|
+
const configPath = import_path.default.join(appDirectory, configDir);
|
|
75
|
+
const dependencies = getPackageConfig(
|
|
76
|
+
appContext.appDirectory,
|
|
77
|
+
appContext.packageName
|
|
78
|
+
) ? [import_path.default.resolve(appDirectory, "./package.json")] : [];
|
|
79
|
+
yield addServerConfigToDeps(
|
|
80
|
+
dependencies,
|
|
81
|
+
appContext.appDirectory,
|
|
82
|
+
appContext.serverConfigFile
|
|
83
|
+
);
|
|
84
|
+
const watched = [
|
|
85
|
+
`${configPath}/html`,
|
|
86
|
+
...extraFiles,
|
|
87
|
+
...dependencies,
|
|
88
|
+
configFile
|
|
89
|
+
].filter(Boolean);
|
|
90
|
+
debug(`watched: %o`, watched);
|
|
91
|
+
const watcher = import_utils.chokidar.watch(watched, {
|
|
92
|
+
cwd: appDirectory,
|
|
93
|
+
ignoreInitial: true,
|
|
94
|
+
ignorePermissionErrors: true,
|
|
95
|
+
ignored: [
|
|
96
|
+
/node_modules/,
|
|
97
|
+
"**/__test__/**",
|
|
98
|
+
"**/*.test.(js|jsx|ts|tsx)",
|
|
99
|
+
"**/*.spec.(js|jsx|ts|tsx)",
|
|
100
|
+
"**/*.stories.(js|jsx|ts|tsx)"
|
|
101
|
+
]
|
|
102
|
+
});
|
|
103
|
+
watcher.on("change", (changed) => {
|
|
104
|
+
const lastHash = hashMap.get(changed);
|
|
105
|
+
const currentHash = md5(
|
|
106
|
+
import_fs.default.readFileSync(import_path.default.join(appDirectory, changed), "utf8")
|
|
107
|
+
);
|
|
108
|
+
if (currentHash !== lastHash) {
|
|
109
|
+
debug(`file change: %s`, changed);
|
|
110
|
+
hashMap.set(changed, currentHash);
|
|
111
|
+
hooksRunner.fileChange({ filename: changed, eventType: "change" });
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
watcher.on("add", (name) => {
|
|
115
|
+
debug(`add file: %s`, name);
|
|
116
|
+
const currentHash = md5(
|
|
117
|
+
import_fs.default.readFileSync(import_path.default.join(appDirectory, name), "utf8")
|
|
118
|
+
);
|
|
119
|
+
hashMap.set(name, currentHash);
|
|
120
|
+
hooksRunner.fileChange({ filename: name, eventType: "add" });
|
|
121
|
+
});
|
|
122
|
+
watcher.on("unlink", (name) => {
|
|
123
|
+
debug(`remove file: %s`, name);
|
|
124
|
+
if (hashMap.has(name)) {
|
|
125
|
+
hashMap.delete(name);
|
|
126
|
+
}
|
|
127
|
+
hooksRunner.fileChange({ filename: name, eventType: "unlink" });
|
|
128
|
+
});
|
|
129
|
+
watcher.on("error", (err) => {
|
|
130
|
+
throw err;
|
|
131
|
+
});
|
|
132
|
+
return watcher;
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
136
|
+
0 && (module.exports = {
|
|
137
|
+
addServerConfigToDeps,
|
|
138
|
+
createFileWatcher
|
|
139
|
+
});
|
|
@@ -1,35 +1,106 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __export = (target, all) => {
|
|
25
|
+
for (var name in all)
|
|
26
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
27
|
+
};
|
|
28
|
+
var __copyProps = (to, from, except, desc) => {
|
|
29
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
30
|
+
for (let key of __getOwnPropNames(from))
|
|
31
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
32
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
33
|
+
}
|
|
34
|
+
return to;
|
|
35
|
+
};
|
|
36
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
37
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
38
|
+
mod
|
|
39
|
+
));
|
|
40
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
41
|
+
var __async = (__this, __arguments, generator) => {
|
|
42
|
+
return new Promise((resolve, reject) => {
|
|
43
|
+
var fulfilled = (value) => {
|
|
44
|
+
try {
|
|
45
|
+
step(generator.next(value));
|
|
46
|
+
} catch (e) {
|
|
47
|
+
reject(e);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
var rejected = (value) => {
|
|
51
|
+
try {
|
|
52
|
+
step(generator.throw(value));
|
|
53
|
+
} catch (e) {
|
|
54
|
+
reject(e);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
58
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
var createServer_exports = {};
|
|
62
|
+
__export(createServer_exports, {
|
|
63
|
+
closeServer: () => closeServer,
|
|
64
|
+
createServer: () => createServer,
|
|
65
|
+
getServer: () => getServer,
|
|
66
|
+
injectDataLoaderPlugin: () => injectDataLoaderPlugin,
|
|
67
|
+
setServer: () => setServer
|
|
5
68
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var _server = require("@modern-js/server");
|
|
9
|
-
|
|
69
|
+
module.exports = __toCommonJS(createServer_exports);
|
|
70
|
+
var import_server = require("@modern-js/server");
|
|
10
71
|
let server = null;
|
|
11
|
-
|
|
12
72
|
const getServer = () => server;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const closeServer =
|
|
73
|
+
const setServer = (newServer) => {
|
|
74
|
+
server = newServer;
|
|
75
|
+
};
|
|
76
|
+
const closeServer = () => __async(void 0, null, function* () {
|
|
17
77
|
if (server) {
|
|
18
|
-
|
|
78
|
+
yield server.close();
|
|
19
79
|
server = null;
|
|
20
80
|
}
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
exports.closeServer = closeServer;
|
|
24
|
-
|
|
25
|
-
const createServer = async options => {
|
|
81
|
+
});
|
|
82
|
+
const createServer = (options) => __async(void 0, null, function* () {
|
|
26
83
|
if (server) {
|
|
27
|
-
|
|
84
|
+
yield server.close();
|
|
28
85
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const app = await server.init();
|
|
86
|
+
server = new import_server.Server(options);
|
|
87
|
+
const app = yield server.init();
|
|
32
88
|
return app;
|
|
89
|
+
});
|
|
90
|
+
const injectDataLoaderPlugin = (internalPlugins) => {
|
|
91
|
+
const DataLoaderPlugin = require.resolve("@modern-js/plugin-data-loader/server");
|
|
92
|
+
return __spreadProps(__spreadValues({}, internalPlugins), {
|
|
93
|
+
"@modern-js/plugin-data-loader": {
|
|
94
|
+
path: DataLoaderPlugin,
|
|
95
|
+
forced: true
|
|
96
|
+
}
|
|
97
|
+
});
|
|
33
98
|
};
|
|
34
|
-
|
|
35
|
-
exports
|
|
99
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
100
|
+
0 && (module.exports = {
|
|
101
|
+
closeServer,
|
|
102
|
+
createServer,
|
|
103
|
+
getServer,
|
|
104
|
+
injectDataLoaderPlugin,
|
|
105
|
+
setServer
|
|
106
|
+
});
|