@modern-js/app-tools 2.0.0-beta.0 → 2.0.0-beta.2
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 +375 -0
- package/dist/js/modern/analyze/generateCode.js +30 -38
- package/dist/js/modern/analyze/getBundleEntry.js +5 -13
- package/dist/js/modern/analyze/getClientRoutes/getRoutes.js +5 -30
- package/dist/js/modern/analyze/getClientRoutes/getRoutesLegacy.js +5 -30
- package/dist/js/modern/analyze/getClientRoutes/utils.js +0 -3
- package/dist/js/modern/analyze/getFileSystemEntry.js +5 -18
- package/dist/js/modern/analyze/getHtmlTemplate.js +3 -10
- package/dist/js/modern/analyze/getServerRoutes.js +25 -38
- package/dist/js/modern/analyze/index.js +90 -48
- package/dist/js/modern/analyze/isDefaultExportFunction.js +0 -4
- package/dist/js/modern/analyze/makeLegalIdentifier.js +0 -2
- package/dist/js/modern/analyze/nestedRoutes.js +8 -33
- package/dist/js/modern/analyze/templates.js +22 -37
- package/dist/js/modern/analyze/utils.js +0 -7
- package/dist/js/modern/builder/builderPlugins/compatModern.js +41 -58
- package/dist/js/modern/builder/index.js +56 -37
- package/dist/js/modern/builder/share.js +1 -5
- package/dist/js/modern/builder/webpackPlugins/htmlAsyncChunkPlugin.js +0 -8
- package/dist/js/modern/builder/webpackPlugins/htmlBottomTemplate.js +2 -13
- package/dist/js/modern/builder/webpackPlugins/routerPlugin.js +97 -0
- package/dist/js/modern/commands/build.js +12 -46
- package/dist/js/modern/commands/dev.js +20 -23
- package/dist/js/modern/commands/inspect.js +4 -19
- package/dist/js/modern/commands/start.js +1 -2
- package/dist/js/modern/config/default.js +207 -0
- package/dist/js/modern/config/index.js +2 -0
- package/dist/js/modern/config/initial/createHtmlConfig.js +32 -0
- package/dist/js/modern/{builder → config/initial}/createOutputConfig.js +19 -18
- package/dist/js/modern/config/initial/createSourceConfig.js +32 -0
- package/dist/js/modern/config/initial/createToolsConfig.js +41 -0
- package/dist/js/modern/config/initial/index.js +11 -0
- package/dist/js/modern/config/initial/inits.js +117 -0
- package/dist/js/modern/config/initial/transformNormalizedConfig.js +40 -0
- package/dist/js/modern/defineConfig.js +12 -0
- package/dist/js/modern/hooks.js +23 -19
- package/dist/js/modern/index.js +12 -19
- package/dist/js/modern/initialize/index.js +72 -0
- package/dist/js/modern/schema/Schema.js +39 -0
- package/dist/js/modern/schema/index.js +139 -0
- package/dist/js/modern/schema/legacy.js +284 -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 +2 -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 +4 -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 +1 -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/config.js +2 -13
- package/dist/js/modern/utils/createFileWatcher.js +82 -0
- package/dist/js/modern/utils/createServer.js +0 -5
- package/dist/js/modern/utils/getSpecifiedEntries.js +0 -6
- package/dist/js/modern/utils/printInstructions.js +2 -1
- package/dist/js/modern/utils/restart.js +17 -0
- package/dist/js/modern/utils/routes.js +0 -2
- package/dist/js/node/analyze/generateCode.js +30 -61
- package/dist/js/node/analyze/getBundleEntry.js +5 -19
- package/dist/js/node/analyze/getClientRoutes/getRoutes.js +5 -45
- package/dist/js/node/analyze/getClientRoutes/getRoutesLegacy.js +5 -45
- package/dist/js/node/analyze/getClientRoutes/index.js +0 -2
- package/dist/js/node/analyze/getClientRoutes/utils.js +0 -14
- package/dist/js/node/analyze/getFileSystemEntry.js +5 -26
- package/dist/js/node/analyze/getHtmlTemplate.js +3 -24
- package/dist/js/node/analyze/getServerRoutes.js +24 -46
- package/dist/js/node/analyze/index.js +91 -70
- package/dist/js/node/analyze/isDefaultExportFunction.js +0 -12
- package/dist/js/node/analyze/makeLegalIdentifier.js +0 -4
- package/dist/js/node/analyze/nestedRoutes.js +8 -41
- package/dist/js/node/analyze/templates.js +22 -47
- package/dist/js/node/analyze/utils.js +0 -20
- package/dist/js/node/builder/builderPlugins/compatModern.js +41 -69
- package/dist/js/node/builder/index.js +57 -51
- package/dist/js/node/builder/share.js +1 -13
- package/dist/js/node/builder/webpackPlugins/htmlAsyncChunkPlugin.js +0 -10
- package/dist/js/node/builder/webpackPlugins/htmlBottomTemplate.js +2 -15
- package/dist/js/node/builder/webpackPlugins/routerPlugin.js +105 -0
- package/dist/js/node/commands/build.js +10 -57
- package/dist/js/node/commands/deploy.js +0 -2
- package/dist/js/node/commands/dev.js +19 -34
- package/dist/js/node/commands/index.js +0 -6
- package/dist/js/node/commands/inspect.js +4 -26
- package/dist/js/node/commands/start.js +1 -11
- package/dist/js/node/config/default.js +214 -0
- package/dist/js/node/config/index.js +31 -0
- package/dist/js/node/config/initial/createHtmlConfig.js +38 -0
- package/dist/js/node/{builder → config/initial}/createOutputConfig.js +19 -20
- package/dist/js/node/config/initial/createSourceConfig.js +38 -0
- package/dist/js/node/config/initial/createToolsConfig.js +47 -0
- package/dist/js/node/config/initial/index.js +24 -0
- package/dist/js/node/config/initial/inits.js +127 -0
- package/dist/js/node/config/initial/transformNormalizedConfig.js +46 -0
- package/dist/js/node/defineConfig.js +20 -0
- package/dist/js/node/exports/server.js +0 -1
- package/dist/js/node/hooks.js +23 -30
- package/dist/js/node/index.js +35 -48
- package/dist/js/node/initialize/index.js +79 -0
- package/dist/js/node/locale/index.js +0 -4
- package/dist/js/node/schema/Schema.js +46 -0
- package/dist/js/node/schema/index.js +152 -0
- package/dist/js/node/schema/legacy.js +291 -0
- package/dist/js/node/types/config/deploy.js +0 -0
- package/dist/js/node/types/config/dev.js +0 -0
- package/dist/js/node/types/config/experiments.js +0 -0
- package/dist/js/node/types/config/html.js +0 -0
- package/dist/js/node/types/config/index.js +16 -0
- package/dist/js/node/types/config/output.js +0 -0
- package/dist/js/node/types/config/performance.js +0 -0
- package/dist/js/node/types/config/security.js +0 -0
- package/dist/js/node/types/config/source.js +0 -0
- package/dist/js/node/types/config/tools.js +0 -0
- package/dist/js/node/types/hooks.js +0 -0
- package/dist/js/node/types/index.js +38 -0
- package/dist/js/node/types/legacyConfig/deploy.js +0 -0
- package/dist/js/node/types/legacyConfig/dev.js +0 -0
- package/dist/js/node/types/legacyConfig/index.js +0 -0
- package/dist/js/node/types/legacyConfig/output.js +5 -0
- package/dist/js/node/types/legacyConfig/source.js +0 -0
- package/dist/js/node/types/legacyConfig/tools.js +0 -0
- package/dist/js/node/utils/commands.js +0 -2
- package/dist/js/node/utils/config.js +2 -26
- package/dist/js/node/utils/createFileWatcher.js +90 -0
- package/dist/js/node/utils/createServer.js +0 -15
- package/dist/js/node/utils/getSpecifiedEntries.js +0 -9
- package/dist/js/node/utils/language.js +0 -2
- package/dist/js/node/utils/printInstructions.js +2 -5
- package/dist/js/node/utils/restart.js +23 -0
- package/dist/js/node/utils/routes.js +0 -5
- package/dist/js/treeshaking/analyze/generateCode.js +58 -101
- package/dist/js/treeshaking/analyze/getBundleEntry.js +12 -20
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutes.js +16 -42
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutesLegacy.js +16 -42
- package/dist/js/treeshaking/analyze/getClientRoutes/utils.js +0 -3
- package/dist/js/treeshaking/analyze/getFileSystemEntry.js +5 -18
- package/dist/js/treeshaking/analyze/getHtmlTemplate.js +3 -27
- package/dist/js/treeshaking/analyze/getServerRoutes.js +29 -41
- package/dist/js/treeshaking/analyze/index.js +195 -91
- package/dist/js/treeshaking/analyze/isDefaultExportFunction.js +0 -4
- package/dist/js/treeshaking/analyze/makeLegalIdentifier.js +0 -2
- package/dist/js/treeshaking/analyze/nestedRoutes.js +9 -51
- package/dist/js/treeshaking/analyze/templates.js +31 -50
- package/dist/js/treeshaking/analyze/utils.js +7 -14
- package/dist/js/treeshaking/builder/builderPlugins/compatModern.js +50 -68
- package/dist/js/treeshaking/builder/index.js +69 -65
- package/dist/js/treeshaking/builder/share.js +1 -5
- package/dist/js/treeshaking/builder/webpackPlugins/htmlAsyncChunkPlugin.js +1 -13
- package/dist/js/treeshaking/builder/webpackPlugins/htmlBottomTemplate.js +2 -14
- package/dist/js/treeshaking/builder/webpackPlugins/routerPlugin.js +121 -0
- package/dist/js/treeshaking/commands/build.js +41 -116
- package/dist/js/treeshaking/commands/deploy.js +0 -3
- package/dist/js/treeshaking/commands/dev.js +38 -46
- package/dist/js/treeshaking/commands/inspect.js +9 -27
- package/dist/js/treeshaking/commands/start.js +1 -9
- package/dist/js/treeshaking/config/default.js +200 -0
- package/dist/js/treeshaking/config/index.js +2 -0
- package/dist/js/treeshaking/config/initial/createHtmlConfig.js +31 -0
- package/dist/js/treeshaking/config/initial/createOutputConfig.js +67 -0
- package/dist/js/treeshaking/config/initial/createSourceConfig.js +41 -0
- package/dist/js/treeshaking/config/initial/createToolsConfig.js +38 -0
- package/dist/js/treeshaking/config/initial/index.js +11 -0
- package/dist/js/treeshaking/config/initial/inits.js +114 -0
- package/dist/js/treeshaking/config/initial/transformNormalizedConfig.js +38 -0
- package/dist/js/treeshaking/defineConfig.js +14 -0
- package/dist/js/treeshaking/hooks.js +23 -19
- package/dist/js/treeshaking/index.js +8 -43
- package/dist/js/treeshaking/initialize/index.js +121 -0
- package/dist/js/treeshaking/schema/Schema.js +75 -0
- package/dist/js/treeshaking/schema/index.js +138 -0
- package/dist/js/treeshaking/schema/legacy.js +273 -0
- package/dist/js/treeshaking/types/config/deploy.js +0 -0
- package/dist/js/treeshaking/types/config/dev.js +0 -0
- package/dist/js/treeshaking/types/config/experiments.js +0 -0
- package/dist/js/treeshaking/types/config/html.js +0 -0
- package/dist/js/treeshaking/types/config/index.js +2 -0
- package/dist/js/treeshaking/types/config/output.js +0 -0
- package/dist/js/treeshaking/types/config/performance.js +0 -0
- package/dist/js/treeshaking/types/config/security.js +0 -0
- package/dist/js/treeshaking/types/config/source.js +0 -0
- package/dist/js/treeshaking/types/config/tools.js +0 -0
- package/dist/js/treeshaking/types/hooks.js +0 -0
- package/dist/js/treeshaking/types/index.js +4 -0
- package/dist/js/treeshaking/types/legacyConfig/deploy.js +0 -0
- package/dist/js/treeshaking/types/legacyConfig/dev.js +0 -0
- package/dist/js/treeshaking/types/legacyConfig/index.js +0 -0
- package/dist/js/treeshaking/types/legacyConfig/output.js +1 -0
- package/dist/js/treeshaking/types/legacyConfig/source.js +0 -0
- package/dist/js/treeshaking/types/legacyConfig/tools.js +0 -0
- package/dist/js/treeshaking/utils/config.js +2 -18
- package/dist/js/treeshaking/utils/createFileWatcher.js +123 -0
- package/dist/js/treeshaking/utils/createServer.js +0 -10
- package/dist/js/treeshaking/utils/getSpecifiedEntries.js +0 -10
- package/dist/js/treeshaking/utils/printInstructions.js +0 -5
- package/dist/js/treeshaking/utils/restart.js +45 -0
- package/dist/js/treeshaking/utils/routes.js +0 -4
- package/dist/types/analyze/generateCode.d.ts +3 -2
- package/dist/types/analyze/getBundleEntry.d.ts +2 -2
- 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 -42
- package/dist/types/analyze/nestedRoutes.d.ts +1 -1
- package/dist/types/analyze/templates.d.ts +4 -2
- package/dist/types/analyze/utils.d.ts +1 -1
- package/dist/types/builder/builderPlugins/compatModern.d.ts +2 -3
- package/dist/types/builder/index.d.ts +7 -8
- package/dist/types/builder/share.d.ts +2 -2
- package/dist/types/builder/webpackPlugins/routerPlugin.d.ts +10 -0
- package/dist/types/commands/build.d.ts +2 -2
- package/dist/types/commands/deploy.d.ts +2 -2
- package/dist/types/commands/dev.d.ts +2 -2
- package/dist/types/commands/inspect.d.ts +6 -1
- package/dist/types/commands/start.d.ts +2 -2
- 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 +7 -0
- package/dist/types/hooks.d.ts +2 -42
- package/dist/types/index.d.ts +5 -7
- package/dist/types/initialize/index.d.ts +3 -0
- 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 +62 -0
- package/dist/types/types/config/output.d.ts +23 -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 +22 -0
- package/dist/types/types/config/tools.d.ts +15 -0
- package/dist/types/types/hooks.d.ts +80 -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 +12 -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 +16 -0
- package/dist/types/utils/config.d.ts +2 -3
- package/dist/types/utils/createFileWatcher.d.ts +3 -0
- package/dist/types/utils/printInstructions.d.ts +3 -3
- package/dist/types/utils/restart.d.ts +3 -0
- package/package.json +26 -25
- package/dist/js/modern/builder/createHtmlConfig.js +0 -58
- package/dist/js/modern/builder/createSourceConfig.js +0 -85
- package/dist/js/modern/builder/createToolsConfig.js +0 -94
- package/dist/js/modern/utils/createCompiler.js +0 -58
- package/dist/js/node/builder/createHtmlConfig.js +0 -76
- package/dist/js/node/builder/createSourceConfig.js +0 -99
- package/dist/js/node/builder/createToolsConfig.js +0 -103
- package/dist/js/node/utils/createCompiler.js +0 -75
- package/dist/js/treeshaking/builder/createHtmlConfig.js +0 -59
- package/dist/js/treeshaking/builder/createOutputConfig.js +0 -67
- package/dist/js/treeshaking/builder/createSourceConfig.js +0 -100
- package/dist/js/treeshaking/builder/createToolsConfig.js +0 -90
- package/dist/js/treeshaking/utils/createCompiler.js +0 -117
- package/dist/types/builder/createHtmlConfig.d.ts +0 -6
- package/dist/types/builder/createOutputConfig.d.ts +0 -3
- package/dist/types/builder/createSourceConfig.d.ts +0 -5
- package/dist/types/builder/createToolsConfig.d.ts +0 -13
- package/dist/types/utils/createCompiler.d.ts +0 -12
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createHtmlConfig = createHtmlConfig;
|
|
7
|
+
function createHtmlConfig(config) {
|
|
8
|
+
const {
|
|
9
|
+
disableHtmlFolder,
|
|
10
|
+
favicon,
|
|
11
|
+
faviconByEntries,
|
|
12
|
+
inject,
|
|
13
|
+
injectByEntries,
|
|
14
|
+
meta,
|
|
15
|
+
metaByEntries,
|
|
16
|
+
mountId,
|
|
17
|
+
title,
|
|
18
|
+
titleByEntries,
|
|
19
|
+
templateParameters,
|
|
20
|
+
templateParametersByEntries,
|
|
21
|
+
crossorigin
|
|
22
|
+
} = config.output;
|
|
23
|
+
return {
|
|
24
|
+
disableHtmlFolder,
|
|
25
|
+
favicon,
|
|
26
|
+
faviconByEntries,
|
|
27
|
+
inject,
|
|
28
|
+
injectByEntries,
|
|
29
|
+
meta,
|
|
30
|
+
metaByEntries,
|
|
31
|
+
mountId,
|
|
32
|
+
title,
|
|
33
|
+
titleByEntries,
|
|
34
|
+
crossorigin,
|
|
35
|
+
templateParameters,
|
|
36
|
+
templateParametersByEntries
|
|
37
|
+
};
|
|
38
|
+
}
|
|
@@ -4,11 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createOutputConfig = createOutputConfig;
|
|
7
|
-
|
|
8
|
-
var _share = require("./share");
|
|
9
|
-
|
|
10
|
-
function createOutputConfig(normalizedConfig, appContext) {
|
|
11
|
-
// TODO: add `externals` options in Modern.
|
|
7
|
+
function createOutputConfig(config) {
|
|
12
8
|
const {
|
|
13
9
|
assetPrefix,
|
|
14
10
|
copy,
|
|
@@ -17,10 +13,13 @@ function createOutputConfig(normalizedConfig, appContext) {
|
|
|
17
13
|
jsPath,
|
|
18
14
|
htmlPath,
|
|
19
15
|
mediaPath,
|
|
16
|
+
enableTsLoader,
|
|
20
17
|
path,
|
|
21
18
|
disableInlineRuntimeChunk,
|
|
19
|
+
disableCssExtract,
|
|
22
20
|
disableMinimize,
|
|
23
21
|
disableSourceMap,
|
|
22
|
+
disableTsChecker,
|
|
24
23
|
enableCssModuleTSDeclaration,
|
|
25
24
|
enableInlineScripts,
|
|
26
25
|
enableInlineStyles,
|
|
@@ -28,23 +27,24 @@ function createOutputConfig(normalizedConfig, appContext) {
|
|
|
28
27
|
dataUriLimit,
|
|
29
28
|
disableAssetsCache,
|
|
30
29
|
enableLatestDecorators,
|
|
31
|
-
disableCssModuleExtension
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
disableCssModuleExtension,
|
|
31
|
+
ssg,
|
|
32
|
+
enableModernMode,
|
|
33
|
+
disableNodePolyfill
|
|
34
|
+
} = config.output;
|
|
35
35
|
return {
|
|
36
36
|
assetPrefix,
|
|
37
|
-
copy
|
|
37
|
+
copy,
|
|
38
38
|
distPath: {
|
|
39
39
|
root: path,
|
|
40
40
|
css: cssPath,
|
|
41
41
|
js: jsPath,
|
|
42
42
|
html: htmlPath,
|
|
43
43
|
// `@modern-js/webpack` output all media files to `dist/media` by default
|
|
44
|
-
svg: mediaPath || '
|
|
45
|
-
image: mediaPath || '
|
|
46
|
-
font: mediaPath || '
|
|
47
|
-
media: mediaPath || '
|
|
44
|
+
svg: mediaPath || 'media',
|
|
45
|
+
image: mediaPath || 'media',
|
|
46
|
+
font: mediaPath || 'media',
|
|
47
|
+
media: mediaPath || 'media'
|
|
48
48
|
},
|
|
49
49
|
dataUriLimit: {
|
|
50
50
|
svg: dataUriLimit,
|
|
@@ -52,24 +52,23 @@ function createOutputConfig(normalizedConfig, appContext) {
|
|
|
52
52
|
font: dataUriLimit,
|
|
53
53
|
media: dataUriLimit
|
|
54
54
|
},
|
|
55
|
+
disableCssExtract,
|
|
55
56
|
disableCssModuleExtension,
|
|
56
57
|
disableInlineRuntimeChunk,
|
|
57
58
|
disableMinimize,
|
|
58
59
|
disableSourceMap,
|
|
60
|
+
disableTsChecker: disableTsChecker || enableTsLoader,
|
|
59
61
|
enableCssModuleTSDeclaration,
|
|
60
62
|
enableInlineScripts,
|
|
61
63
|
enableInlineStyles,
|
|
62
64
|
polyfill,
|
|
63
|
-
// We need to do this in the app-tools prepare hook because some files will be generated into the dist directory in the analyze process
|
|
64
|
-
cleanDistPath: false,
|
|
65
65
|
disableFilenameHash: disableAssetsCache,
|
|
66
66
|
enableLatestDecorators,
|
|
67
67
|
filename: {
|
|
68
68
|
css: cssModuleLocalIdentName
|
|
69
69
|
},
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
enableAssetFallback: true
|
|
70
|
+
ssg,
|
|
71
|
+
enableModernMode,
|
|
72
|
+
disableNodePolyfill
|
|
74
73
|
};
|
|
75
74
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createSourceConfig = createSourceConfig;
|
|
7
|
+
function createSourceConfig(config) {
|
|
8
|
+
const {
|
|
9
|
+
alias,
|
|
10
|
+
envVars,
|
|
11
|
+
globalVars,
|
|
12
|
+
include,
|
|
13
|
+
moduleScopes,
|
|
14
|
+
preEntry,
|
|
15
|
+
entries,
|
|
16
|
+
enableAsyncEntry,
|
|
17
|
+
disableDefaultEntries,
|
|
18
|
+
entriesDir,
|
|
19
|
+
configDir
|
|
20
|
+
} = config.source;
|
|
21
|
+
const builderGlobalVars = globalVars || {};
|
|
22
|
+
for (const envVar of envVars || []) {
|
|
23
|
+
const envVarValue = process.env[envVar];
|
|
24
|
+
envVarValue && (builderGlobalVars[`process.env.${envVar}`] = envVarValue);
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
alias,
|
|
28
|
+
moduleScopes,
|
|
29
|
+
globalVars: builderGlobalVars,
|
|
30
|
+
include,
|
|
31
|
+
preEntry,
|
|
32
|
+
entries,
|
|
33
|
+
enableAsyncEntry,
|
|
34
|
+
disableDefaultEntries,
|
|
35
|
+
entriesDir,
|
|
36
|
+
configDir
|
|
37
|
+
};
|
|
38
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createToolsConfig = createToolsConfig;
|
|
7
|
+
function createToolsConfig(config) {
|
|
8
|
+
const {
|
|
9
|
+
autoprefixer,
|
|
10
|
+
babel,
|
|
11
|
+
minifyCss,
|
|
12
|
+
terser,
|
|
13
|
+
webpack,
|
|
14
|
+
webpackChain,
|
|
15
|
+
tsLoader,
|
|
16
|
+
styledComponents,
|
|
17
|
+
sass,
|
|
18
|
+
postcss,
|
|
19
|
+
less,
|
|
20
|
+
htmlPlugin,
|
|
21
|
+
devServer,
|
|
22
|
+
tailwindcss,
|
|
23
|
+
jest,
|
|
24
|
+
esbuild
|
|
25
|
+
} = config.tools;
|
|
26
|
+
const {
|
|
27
|
+
enableTsLoader
|
|
28
|
+
} = config.output;
|
|
29
|
+
return {
|
|
30
|
+
tsLoader: enableTsLoader ? tsLoader : undefined,
|
|
31
|
+
autoprefixer,
|
|
32
|
+
babel,
|
|
33
|
+
minifyCss,
|
|
34
|
+
terser,
|
|
35
|
+
webpack,
|
|
36
|
+
webpackChain,
|
|
37
|
+
styledComponents,
|
|
38
|
+
sass,
|
|
39
|
+
postcss,
|
|
40
|
+
less,
|
|
41
|
+
htmlPlugin,
|
|
42
|
+
devServer,
|
|
43
|
+
tailwindcss,
|
|
44
|
+
jest,
|
|
45
|
+
esbuild
|
|
46
|
+
};
|
|
47
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.checkIsLegacyConfig = checkIsLegacyConfig;
|
|
7
|
+
exports.initialNormalizedConfig = initialNormalizedConfig;
|
|
8
|
+
Object.defineProperty(exports, "transformNormalizedConfig", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () {
|
|
11
|
+
return _transformNormalizedConfig.transformNormalizedConfig;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
var _inits = require("./inits");
|
|
15
|
+
var _transformNormalizedConfig = require("./transformNormalizedConfig");
|
|
16
|
+
function checkIsLegacyConfig(config) {
|
|
17
|
+
return Boolean(config.legacy);
|
|
18
|
+
}
|
|
19
|
+
function initialNormalizedConfig(config, appContext) {
|
|
20
|
+
(0, _inits.initHtmlConfig)(config, appContext);
|
|
21
|
+
(0, _inits.initSourceConfig)(config, appContext);
|
|
22
|
+
(0, _inits.initToolsConfig)(config);
|
|
23
|
+
return config;
|
|
24
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.initHtmlConfig = initHtmlConfig;
|
|
7
|
+
exports.initSourceConfig = initSourceConfig;
|
|
8
|
+
exports.initToolsConfig = initToolsConfig;
|
|
9
|
+
var _path = _interopRequireWildcard(require("path"));
|
|
10
|
+
var _utils = require("@modern-js/utils");
|
|
11
|
+
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); }
|
|
12
|
+
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; }
|
|
13
|
+
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; }
|
|
14
|
+
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; }
|
|
15
|
+
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; }
|
|
16
|
+
function initHtmlConfig(config, appContext) {
|
|
17
|
+
const ICON_EXTENSIONS = ['png', 'jpg', 'jpeg', 'svg', 'ico'];
|
|
18
|
+
config.html.appIcon = createBuilderAppIcon(config, appContext);
|
|
19
|
+
config.html.favicon = createBuilderFavicon(config, appContext);
|
|
20
|
+
return config.html;
|
|
21
|
+
function createBuilderAppIcon(config, appContext) {
|
|
22
|
+
const {
|
|
23
|
+
configDir
|
|
24
|
+
} = config.source;
|
|
25
|
+
const appIcon = (0, _utils.findExists)(ICON_EXTENSIONS.map(ext => _path.default.resolve(appContext.appDirectory, configDir || './config', `icon.${ext}`)));
|
|
26
|
+
return typeof appIcon === 'string' ? appIcon : undefined;
|
|
27
|
+
}
|
|
28
|
+
function createBuilderFavicon(config, appContext) {
|
|
29
|
+
const {
|
|
30
|
+
configDir
|
|
31
|
+
} = config.source;
|
|
32
|
+
const {
|
|
33
|
+
favicon
|
|
34
|
+
} = config.html;
|
|
35
|
+
const defaultFavicon = (0, _utils.findExists)(ICON_EXTENSIONS.map(ext => _path.default.resolve(appContext.appDirectory, configDir || './config', `favicon.${ext}`)));
|
|
36
|
+
return favicon || defaultFavicon || undefined;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function initSourceConfig(config, appContext) {
|
|
40
|
+
config.source.include = createBuilderInclude(config, appContext);
|
|
41
|
+
config.source.moduleScopes = createBuilderModuleScope(config);
|
|
42
|
+
function createBuilderInclude(config, appContext) {
|
|
43
|
+
const {
|
|
44
|
+
include
|
|
45
|
+
} = config.source;
|
|
46
|
+
const defaultInclude = [appContext.internalDirectory];
|
|
47
|
+
const transformInclude = (include || []).map(include => {
|
|
48
|
+
if (typeof include === 'string') {
|
|
49
|
+
if ((0, _path.isAbsolute)(include)) {
|
|
50
|
+
return include;
|
|
51
|
+
}
|
|
52
|
+
return new RegExp(include);
|
|
53
|
+
}
|
|
54
|
+
return include;
|
|
55
|
+
}).concat(defaultInclude); // concat default Include
|
|
56
|
+
|
|
57
|
+
const root = (0, _utils.findMonorepoRoot)(appContext.appDirectory);
|
|
58
|
+
if (!root) {
|
|
59
|
+
return transformInclude;
|
|
60
|
+
}
|
|
61
|
+
const modernjsMonorepo = (0, _utils.isModernjsMonorepo)(root);
|
|
62
|
+
if (modernjsMonorepo) {
|
|
63
|
+
const paths = _utils.globby.sync(_path.posix.join(root, 'features', '**', 'package.json'), {
|
|
64
|
+
ignore: ['**/node_modules/**/*']
|
|
65
|
+
}).map(pathname => (0, _path.dirname)(pathname) + _path.sep);
|
|
66
|
+
return [...paths, ...transformInclude];
|
|
67
|
+
}
|
|
68
|
+
return transformInclude;
|
|
69
|
+
}
|
|
70
|
+
function createBuilderModuleScope(config) {
|
|
71
|
+
const {
|
|
72
|
+
moduleScopes
|
|
73
|
+
} = config.source;
|
|
74
|
+
if (moduleScopes) {
|
|
75
|
+
let builderModuleScope = [];
|
|
76
|
+
const DEFAULT_SCOPES = ['./src', './shared', /node_modules/];
|
|
77
|
+
if (Array.isArray(moduleScopes)) {
|
|
78
|
+
if (isPrimitiveScope(moduleScopes)) {
|
|
79
|
+
builderModuleScope = DEFAULT_SCOPES.concat(moduleScopes);
|
|
80
|
+
} else {
|
|
81
|
+
builderModuleScope = [DEFAULT_SCOPES, ...moduleScopes];
|
|
82
|
+
}
|
|
83
|
+
} else {
|
|
84
|
+
builderModuleScope = [DEFAULT_SCOPES, moduleScopes];
|
|
85
|
+
}
|
|
86
|
+
return builderModuleScope;
|
|
87
|
+
} else {
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
function isPrimitiveScope(items) {
|
|
91
|
+
return items.every(item => typeof item === 'string' || Object.prototype.toString.call(item) === '[object RegExp]');
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function initToolsConfig(config) {
|
|
96
|
+
const defaultTsChecker = {
|
|
97
|
+
issue: {
|
|
98
|
+
include: [{
|
|
99
|
+
file: '**/src/**/*'
|
|
100
|
+
}],
|
|
101
|
+
exclude: [{
|
|
102
|
+
file: '**/*.(spec|test).ts'
|
|
103
|
+
}, {
|
|
104
|
+
file: '**/node_modules/**/*'
|
|
105
|
+
}]
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
const {
|
|
109
|
+
tsChecker,
|
|
110
|
+
tsLoader,
|
|
111
|
+
htmlPlugin
|
|
112
|
+
} = config.tools;
|
|
113
|
+
config.tools.tsChecker = (0, _utils.applyOptionsChain)(defaultTsChecker, tsChecker);
|
|
114
|
+
tsLoader && (config.tools.tsLoader = (tsLoaderConfig, utils) => {
|
|
115
|
+
(0, _utils.applyOptionsChain)(_objectSpread(_objectSpread({}, tsLoaderConfig), {}, {
|
|
116
|
+
transpileOnly: false,
|
|
117
|
+
allowTsInNodeModules: true
|
|
118
|
+
}), tsLoader || {}, utils);
|
|
119
|
+
});
|
|
120
|
+
config.tools.htmlPlugin = [config => _objectSpread(_objectSpread({}, config), {}, {
|
|
121
|
+
minify: typeof config.minify === 'object' ? _objectSpread(_objectSpread({}, config.minify), {}, {
|
|
122
|
+
removeComments: false
|
|
123
|
+
}) : config.minify
|
|
124
|
+
}),
|
|
125
|
+
// eslint-disable-next-line no-nested-ternary
|
|
126
|
+
...(Array.isArray(htmlPlugin) ? htmlPlugin : htmlPlugin ? [htmlPlugin] : [])];
|
|
127
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.transformNormalizedConfig = transformNormalizedConfig;
|
|
7
|
+
var _createToolsConfig = require("./createToolsConfig");
|
|
8
|
+
var _createSourceConfig = require("./createSourceConfig");
|
|
9
|
+
var _createOutputConfig = require("./createOutputConfig");
|
|
10
|
+
var _createHtmlConfig = require("./createHtmlConfig");
|
|
11
|
+
function transformNormalizedConfig(config) {
|
|
12
|
+
const html = (0, _createHtmlConfig.createHtmlConfig)(config);
|
|
13
|
+
const output = (0, _createOutputConfig.createOutputConfig)(config);
|
|
14
|
+
const source = (0, _createSourceConfig.createSourceConfig)(config);
|
|
15
|
+
const tools = (0, _createToolsConfig.createToolsConfig)(config);
|
|
16
|
+
const {
|
|
17
|
+
bff,
|
|
18
|
+
dev,
|
|
19
|
+
deploy,
|
|
20
|
+
runtime,
|
|
21
|
+
runtimeByEntries,
|
|
22
|
+
server,
|
|
23
|
+
cliOptions,
|
|
24
|
+
plugins,
|
|
25
|
+
testing
|
|
26
|
+
} = config;
|
|
27
|
+
return {
|
|
28
|
+
source,
|
|
29
|
+
html,
|
|
30
|
+
output,
|
|
31
|
+
tools,
|
|
32
|
+
bff,
|
|
33
|
+
dev,
|
|
34
|
+
deploy,
|
|
35
|
+
runtime,
|
|
36
|
+
runtimeByEntries,
|
|
37
|
+
server,
|
|
38
|
+
cliOptions,
|
|
39
|
+
testing,
|
|
40
|
+
plugins: plugins,
|
|
41
|
+
security: {},
|
|
42
|
+
_raw: {},
|
|
43
|
+
experiments: {},
|
|
44
|
+
performance: {}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.defineLegacyConfig = exports.defineConfig = void 0;
|
|
7
|
+
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; }
|
|
8
|
+
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; }
|
|
9
|
+
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; }
|
|
10
|
+
const defineConfig = config => config;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated
|
|
14
|
+
* Using defineConfig first.
|
|
15
|
+
*/
|
|
16
|
+
exports.defineConfig = defineConfig;
|
|
17
|
+
const defineLegacyConfig = config => _objectSpread(_objectSpread({}, config), {}, {
|
|
18
|
+
legacy: true
|
|
19
|
+
});
|
|
20
|
+
exports.defineLegacyConfig = defineLegacyConfig;
|
package/dist/js/node/hooks.js
CHANGED
|
@@ -3,37 +3,30 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.hooks =
|
|
7
|
-
|
|
6
|
+
exports.hooks = void 0;
|
|
8
7
|
var _plugin = require("@modern-js/plugin");
|
|
9
|
-
|
|
10
|
-
const beforeDev = (0, _plugin.createAsyncWorkflow)();
|
|
11
|
-
exports.beforeDev = beforeDev;
|
|
12
|
-
const afterDev = (0, _plugin.createAsyncWorkflow)();
|
|
13
|
-
exports.afterDev = afterDev;
|
|
14
|
-
const beforeCreateCompiler = (0, _plugin.createAsyncWorkflow)();
|
|
15
|
-
exports.beforeCreateCompiler = beforeCreateCompiler;
|
|
16
|
-
const afterCreateCompiler = (0, _plugin.createAsyncWorkflow)();
|
|
17
|
-
exports.afterCreateCompiler = afterCreateCompiler;
|
|
18
|
-
const beforePrintInstructions = (0, _plugin.createAsyncWaterfall)();
|
|
19
|
-
exports.beforePrintInstructions = beforePrintInstructions;
|
|
20
|
-
const beforeBuild = (0, _plugin.createAsyncWorkflow)();
|
|
21
|
-
exports.beforeBuild = beforeBuild;
|
|
22
|
-
const afterBuild = (0, _plugin.createAsyncWorkflow)();
|
|
23
|
-
exports.afterBuild = afterBuild;
|
|
24
|
-
const beforeDeploy = (0, _plugin.createAsyncWorkflow)();
|
|
25
|
-
exports.beforeDeploy = beforeDeploy;
|
|
26
|
-
const afterDeploy = (0, _plugin.createAsyncWorkflow)();
|
|
27
|
-
exports.afterDeploy = afterDeploy;
|
|
28
8
|
const hooks = {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
9
|
+
modifyEntryExport: (0, _plugin.createAsyncWaterfall)(),
|
|
10
|
+
modifyEntryImports: (0, _plugin.createAsyncWaterfall)(),
|
|
11
|
+
modifyEntryRuntimePlugins: (0, _plugin.createAsyncWaterfall)(),
|
|
12
|
+
modifyEntryRenderFunction: (0, _plugin.createAsyncWaterfall)(),
|
|
13
|
+
modifyAsyncEntry: (0, _plugin.createAsyncWaterfall)(),
|
|
14
|
+
modifyFileSystemRoutes: (0, _plugin.createAsyncWaterfall)(),
|
|
15
|
+
modifyServerRoutes: (0, _plugin.createAsyncWaterfall)(),
|
|
16
|
+
htmlPartials: (0, _plugin.createAsyncWaterfall)(),
|
|
17
|
+
beforeGenerateRoutes: (0, _plugin.createAsyncWaterfall)(),
|
|
18
|
+
addDefineTypes: (0, _plugin.createAsyncWaterfall)(),
|
|
19
|
+
beforeDev: (0, _plugin.createAsyncWorkflow)(),
|
|
20
|
+
afterDev: (0, _plugin.createAsyncWorkflow)(),
|
|
21
|
+
beforeCreateCompiler: (0, _plugin.createAsyncWorkflow)(),
|
|
22
|
+
afterCreateCompiler: (0, _plugin.createAsyncWorkflow)(),
|
|
23
|
+
beforePrintInstructions: (0, _plugin.createAsyncWaterfall)(),
|
|
24
|
+
beforeBuild: (0, _plugin.createAsyncWorkflow)(),
|
|
25
|
+
afterBuild: (0, _plugin.createAsyncWorkflow)(),
|
|
26
|
+
beforeDeploy: (0, _plugin.createAsyncWorkflow)(),
|
|
27
|
+
afterDeploy: (0, _plugin.createAsyncWorkflow)(),
|
|
28
|
+
watchFiles: (0, _plugin.createParallelWorkflow)(),
|
|
29
|
+
fileChange: (0, _plugin.createAsyncWorkflow)(),
|
|
30
|
+
beforeRestart: (0, _plugin.createAsyncWorkflow)()
|
|
38
31
|
};
|
|
39
32
|
exports.hooks = hooks;
|
package/dist/js/node/index.js
CHANGED
|
@@ -3,64 +3,59 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
var _exportNames = {};
|
|
6
7
|
exports.default = void 0;
|
|
7
|
-
Object.defineProperty(exports, "defineConfig", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function () {
|
|
10
|
-
return _core.defineConfig;
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
Object.defineProperty(exports, "hooks", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function () {
|
|
16
|
-
return _hooks.hooks;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
|
|
20
8
|
var _path = _interopRequireDefault(require("path"));
|
|
21
|
-
|
|
22
|
-
var _core = require("@modern-js/core");
|
|
23
|
-
|
|
24
|
-
var _pluginJarvis = _interopRequireDefault(require("@modern-js/plugin-jarvis"));
|
|
25
|
-
|
|
9
|
+
var _pluginLint = _interopRequireDefault(require("@modern-js/plugin-lint"));
|
|
26
10
|
var _utils = require("@modern-js/utils");
|
|
27
|
-
|
|
28
11
|
var _analyze = _interopRequireDefault(require("./analyze"));
|
|
29
|
-
|
|
12
|
+
var _initialize = _interopRequireDefault(require("./initialize"));
|
|
30
13
|
var _hooks = require("./hooks");
|
|
31
|
-
|
|
32
14
|
var _locale = require("./locale");
|
|
33
|
-
|
|
34
15
|
var _language = require("./utils/language");
|
|
35
|
-
|
|
36
16
|
var _commands = require("./utils/commands");
|
|
37
|
-
|
|
17
|
+
var _restart = require("./utils/restart");
|
|
18
|
+
var _defineConfig = require("./defineConfig");
|
|
19
|
+
Object.keys(_defineConfig).forEach(function (key) {
|
|
20
|
+
if (key === "default" || key === "__esModule") return;
|
|
21
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
22
|
+
if (key in exports && exports[key] === _defineConfig[key]) return;
|
|
23
|
+
Object.defineProperty(exports, key, {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () {
|
|
26
|
+
return _defineConfig[key];
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
var _types = require("./types");
|
|
31
|
+
Object.keys(_types).forEach(function (key) {
|
|
32
|
+
if (key === "default" || key === "__esModule") return;
|
|
33
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
34
|
+
if (key in exports && exports[key] === _types[key]) return;
|
|
35
|
+
Object.defineProperty(exports, key, {
|
|
36
|
+
enumerable: true,
|
|
37
|
+
get: function () {
|
|
38
|
+
return _types[key];
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
});
|
|
38
42
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
39
|
-
|
|
40
43
|
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; }
|
|
41
|
-
|
|
42
44
|
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; }
|
|
43
|
-
|
|
44
45
|
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; }
|
|
45
|
-
|
|
46
46
|
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); }
|
|
47
|
-
|
|
48
47
|
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; }
|
|
49
|
-
|
|
50
48
|
const upgradeModel = _utils.Import.lazy('@modern-js/upgrade', require);
|
|
51
|
-
|
|
52
49
|
var _default = () => ({
|
|
53
50
|
name: '@modern-js/app-tools',
|
|
54
|
-
post: ['@modern-js/plugin-analyze', '@modern-js/plugin-ssr', '@modern-js/plugin-state', '@modern-js/plugin-router', '@modern-js/plugin-router-legacy', '@modern-js/plugin-polyfill'],
|
|
51
|
+
post: ['@modern-js/plugin-initialize', '@modern-js/plugin-analyze', '@modern-js/plugin-ssr', '@modern-js/plugin-document', '@modern-js/plugin-state', '@modern-js/plugin-router', '@modern-js/plugin-router-legacy', '@modern-js/plugin-polyfill'],
|
|
55
52
|
registerHook: _hooks.hooks,
|
|
56
|
-
usePlugins: [(0, _analyze.default)(), (0,
|
|
53
|
+
usePlugins: [(0, _initialize.default)(), (0, _analyze.default)(), (0, _pluginLint.default)()],
|
|
57
54
|
setup: api => {
|
|
58
55
|
const locale = (0, _language.getLocaleLanguage)();
|
|
59
|
-
|
|
60
56
|
_locale.i18n.changeLanguage({
|
|
61
57
|
locale
|
|
62
58
|
});
|
|
63
|
-
|
|
64
59
|
return {
|
|
65
60
|
commands({
|
|
66
61
|
program
|
|
@@ -75,9 +70,9 @@ var _default = () => ({
|
|
|
75
70
|
const {
|
|
76
71
|
build
|
|
77
72
|
} = await Promise.resolve().then(() => _interopRequireWildcard(require("./commands/build")));
|
|
78
|
-
await build(api, options);
|
|
73
|
+
await build(api, options);
|
|
74
|
+
// force exit after build.
|
|
79
75
|
// eslint-disable-next-line no-process-exit
|
|
80
|
-
|
|
81
76
|
process.exit(0);
|
|
82
77
|
});
|
|
83
78
|
program.command('start').usage('[options]').description(_locale.i18n.t(_locale.localeKeys.command.start.describe)).option('--api-only', _locale.i18n.t(_locale.localeKeys.command.dev.apiOnly)).option('-c --config <config>', _locale.i18n.t(_locale.localeKeys.command.shared.config)).action(async () => {
|
|
@@ -94,8 +89,8 @@ var _default = () => ({
|
|
|
94
89
|
const {
|
|
95
90
|
deploy
|
|
96
91
|
} = await Promise.resolve().then(() => _interopRequireWildcard(require("./commands/deploy")));
|
|
97
|
-
await deploy(api, options);
|
|
98
|
-
|
|
92
|
+
await deploy(api, options);
|
|
93
|
+
// eslint-disable-next-line no-process-exit
|
|
99
94
|
process.exit(0);
|
|
100
95
|
});
|
|
101
96
|
program.command('new').usage('[options]').description(_locale.i18n.t(_locale.localeKeys.command.new.describe)).option('-d, --debug', _locale.i18n.t(_locale.localeKeys.command.new.debug), false).option('-c, --config <config>', _locale.i18n.t(_locale.localeKeys.command.new.config)).option('--dist-tag <tag>', _locale.i18n.t(_locale.localeKeys.command.new.distTag)).option('--registry', _locale.i18n.t(_locale.localeKeys.command.new.registry)).action(async options => {
|
|
@@ -114,16 +109,13 @@ var _default = () => ({
|
|
|
114
109
|
});
|
|
115
110
|
upgradeModel.defineCommand(program.command('upgrade'));
|
|
116
111
|
},
|
|
117
|
-
|
|
118
112
|
async prepare() {
|
|
119
113
|
const command = (0, _commands.getCommand)();
|
|
120
|
-
|
|
121
114
|
if (command === 'dev' || command === 'build') {
|
|
122
115
|
const appContext = api.useAppContext();
|
|
123
116
|
await (0, _utils.emptyDir)(appContext.distDirectory);
|
|
124
117
|
}
|
|
125
118
|
},
|
|
126
|
-
|
|
127
119
|
// 这里会被 core/initWatcher 监听的文件变动触发,如果是 src 目录下的文件变动,则不做 restart
|
|
128
120
|
async fileChange(e) {
|
|
129
121
|
const {
|
|
@@ -135,24 +127,19 @@ var _default = () => ({
|
|
|
135
127
|
appDirectory,
|
|
136
128
|
srcDirectory
|
|
137
129
|
} = appContext;
|
|
138
|
-
|
|
139
130
|
const absolutePath = _path.default.resolve(appDirectory, filename);
|
|
140
|
-
|
|
141
131
|
if (!absolutePath.includes(srcDirectory) && (eventType === 'change' || eventType === 'unlink')) {
|
|
142
132
|
const {
|
|
143
133
|
closeServer
|
|
144
134
|
} = await Promise.resolve().then(() => _interopRequireWildcard(require("./utils/createServer")));
|
|
145
135
|
await closeServer();
|
|
146
|
-
await
|
|
136
|
+
await (0, _restart.restart)(api.useHookRunners());
|
|
147
137
|
}
|
|
148
138
|
},
|
|
149
|
-
|
|
150
139
|
async beforeRestart() {
|
|
151
140
|
(0, _utils.cleanRequireCache)([require.resolve("./analyze")]);
|
|
152
141
|
}
|
|
153
|
-
|
|
154
142
|
};
|
|
155
143
|
}
|
|
156
144
|
});
|
|
157
|
-
|
|
158
145
|
exports.default = _default;
|