@modern-js/app-tools 2.0.0-beta.1 → 2.0.0-beta.3
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 +445 -0
- package/bin/modern.js +10 -1
- package/dist/js/modern/analyze/constants.js +2 -0
- package/dist/js/modern/analyze/generateCode.js +39 -19
- package/dist/js/modern/analyze/getBundleEntry.js +1 -1
- package/dist/js/modern/analyze/getFileSystemEntry.js +1 -1
- package/dist/js/modern/analyze/getHtmlTemplate.js +1 -1
- package/dist/js/modern/analyze/getServerRoutes.js +8 -4
- package/dist/js/modern/analyze/index.js +12 -27
- package/dist/js/modern/analyze/nestedRoutes.js +17 -6
- package/dist/js/modern/analyze/templates.js +59 -27
- package/dist/js/modern/analyze/utils.js +30 -4
- package/dist/js/modern/builder/builderPlugins/compatModern.js +18 -12
- package/dist/js/modern/builder/index.js +31 -16
- package/dist/js/modern/builder/loaders/routerLoader.js +20 -0
- package/dist/js/modern/builder/loaders/serverModuleLoader.js +4 -0
- package/dist/js/modern/builder/share.js +1 -1
- package/dist/js/modern/commands/build.js +8 -2
- package/dist/js/modern/commands/dev.js +37 -32
- package/dist/js/modern/commands/inspect.js +4 -2
- package/dist/js/modern/config/default.js +206 -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 +16 -15
- 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 +7 -5
- 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 +1 -1
- package/dist/js/modern/utils/createFileWatcher.js +82 -0
- package/dist/js/modern/utils/restart.js +17 -0
- package/dist/js/node/analyze/constants.js +5 -1
- package/dist/js/node/analyze/generateCode.js +37 -17
- package/dist/js/node/analyze/getBundleEntry.js +1 -1
- package/dist/js/node/analyze/getFileSystemEntry.js +1 -1
- package/dist/js/node/analyze/getHtmlTemplate.js +1 -1
- package/dist/js/node/analyze/getServerRoutes.js +8 -4
- package/dist/js/node/analyze/index.js +13 -39
- package/dist/js/node/analyze/nestedRoutes.js +15 -4
- package/dist/js/node/analyze/templates.js +60 -27
- package/dist/js/node/analyze/utils.js +31 -3
- package/dist/js/node/builder/builderPlugins/compatModern.js +18 -12
- package/dist/js/node/builder/index.js +32 -16
- package/dist/js/node/builder/loaders/routerLoader.js +27 -0
- package/dist/js/node/builder/loaders/serverModuleLoader.js +11 -0
- package/dist/js/node/builder/share.js +1 -1
- package/dist/js/node/commands/build.js +8 -2
- package/dist/js/node/commands/dev.js +37 -32
- package/dist/js/node/commands/inspect.js +4 -2
- package/dist/js/node/config/default.js +213 -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 +16 -15
- 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/hooks.js +23 -28
- package/dist/js/node/index.js +30 -16
- package/dist/js/node/initialize/index.js +79 -0
- 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/config.js +1 -1
- package/dist/js/node/utils/createFileWatcher.js +91 -0
- package/dist/js/node/utils/restart.js +23 -0
- package/dist/js/treeshaking/analyze/constants.js +2 -0
- package/dist/js/treeshaking/analyze/generateCode.js +138 -82
- package/dist/js/treeshaking/analyze/getBundleEntry.js +1 -1
- package/dist/js/treeshaking/analyze/getFileSystemEntry.js +1 -1
- package/dist/js/treeshaking/analyze/getHtmlTemplate.js +1 -1
- package/dist/js/treeshaking/analyze/getServerRoutes.js +7 -5
- package/dist/js/treeshaking/analyze/index.js +10 -26
- package/dist/js/treeshaking/analyze/nestedRoutes.js +98 -55
- package/dist/js/treeshaking/analyze/templates.js +175 -101
- package/dist/js/treeshaking/analyze/utils.js +80 -4
- package/dist/js/treeshaking/builder/builderPlugins/compatModern.js +18 -12
- package/dist/js/treeshaking/builder/index.js +29 -16
- package/dist/js/treeshaking/builder/loaders/routerLoader.js +14 -0
- package/dist/js/treeshaking/builder/loaders/serverModuleLoader.js +4 -0
- package/dist/js/treeshaking/builder/share.js +1 -1
- package/dist/js/treeshaking/commands/build.js +33 -23
- package/dist/js/treeshaking/commands/dev.js +56 -43
- package/dist/js/treeshaking/commands/inspect.js +8 -3
- package/dist/js/treeshaking/config/default.js +199 -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 +70 -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 +7 -5
- 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 +1 -1
- package/dist/js/treeshaking/utils/createFileWatcher.js +123 -0
- package/dist/js/treeshaking/utils/restart.js +45 -0
- package/dist/types/analyze/constants.d.ts +2 -0
- 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 -41
- package/dist/types/analyze/templates.d.ts +9 -8
- package/dist/types/analyze/utils.d.ts +10 -2
- package/dist/types/builder/builderPlugins/compatModern.d.ts +2 -2
- package/dist/types/builder/index.d.ts +5 -2
- 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 +2 -2
- 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 +9 -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 -5
- 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 +22 -0
- package/dist/types/types/hooks.d.ts +81 -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 -2
- package/dist/types/utils/createFileWatcher.d.ts +4 -0
- package/dist/types/utils/printInstructions.d.ts +3 -3
- package/dist/types/utils/restart.d.ts +3 -0
- package/lib/types.d.ts +1 -1
- package/package.json +28 -25
- package/dist/js/modern/builder/createHtmlConfig.js +0 -58
- package/dist/js/modern/builder/createSourceConfig.js +0 -74
- package/dist/js/modern/builder/createToolsConfig.js +0 -87
- package/dist/js/node/builder/createHtmlConfig.js +0 -68
- package/dist/js/node/builder/createSourceConfig.js +0 -82
- package/dist/js/node/builder/createToolsConfig.js +0 -94
- package/dist/js/treeshaking/builder/createHtmlConfig.js +0 -59
- package/dist/js/treeshaking/builder/createOutputConfig.js +0 -70
- package/dist/js/treeshaking/builder/createSourceConfig.js +0 -88
- package/dist/js/treeshaking/builder/createToolsConfig.js +0 -85
- 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
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export function createHtmlConfig(config) {
|
|
2
|
+
var _config$output = config.output,
|
|
3
|
+
disableHtmlFolder = _config$output.disableHtmlFolder,
|
|
4
|
+
favicon = _config$output.favicon,
|
|
5
|
+
faviconByEntries = _config$output.faviconByEntries,
|
|
6
|
+
inject = _config$output.inject,
|
|
7
|
+
injectByEntries = _config$output.injectByEntries,
|
|
8
|
+
meta = _config$output.meta,
|
|
9
|
+
metaByEntries = _config$output.metaByEntries,
|
|
10
|
+
mountId = _config$output.mountId,
|
|
11
|
+
title = _config$output.title,
|
|
12
|
+
titleByEntries = _config$output.titleByEntries,
|
|
13
|
+
templateParameters = _config$output.templateParameters,
|
|
14
|
+
templateParametersByEntries = _config$output.templateParametersByEntries,
|
|
15
|
+
crossorigin = _config$output.crossorigin;
|
|
16
|
+
return {
|
|
17
|
+
disableHtmlFolder: disableHtmlFolder,
|
|
18
|
+
favicon: favicon,
|
|
19
|
+
faviconByEntries: faviconByEntries,
|
|
20
|
+
inject: inject,
|
|
21
|
+
injectByEntries: injectByEntries,
|
|
22
|
+
meta: meta,
|
|
23
|
+
metaByEntries: metaByEntries,
|
|
24
|
+
mountId: mountId,
|
|
25
|
+
title: title,
|
|
26
|
+
titleByEntries: titleByEntries,
|
|
27
|
+
crossorigin: crossorigin,
|
|
28
|
+
templateParameters: templateParameters,
|
|
29
|
+
templateParametersByEntries: templateParametersByEntries
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export function createOutputConfig(config) {
|
|
2
|
+
var _config$output = config.output,
|
|
3
|
+
assetPrefix = _config$output.assetPrefix,
|
|
4
|
+
copy = _config$output.copy,
|
|
5
|
+
cssModuleLocalIdentName = _config$output.cssModuleLocalIdentName,
|
|
6
|
+
cssPath = _config$output.cssPath,
|
|
7
|
+
jsPath = _config$output.jsPath,
|
|
8
|
+
htmlPath = _config$output.htmlPath,
|
|
9
|
+
mediaPath = _config$output.mediaPath,
|
|
10
|
+
enableTsLoader = _config$output.enableTsLoader,
|
|
11
|
+
path = _config$output.path,
|
|
12
|
+
disableInlineRuntimeChunk = _config$output.disableInlineRuntimeChunk,
|
|
13
|
+
disableCssExtract = _config$output.disableCssExtract,
|
|
14
|
+
disableMinimize = _config$output.disableMinimize,
|
|
15
|
+
disableSourceMap = _config$output.disableSourceMap,
|
|
16
|
+
disableTsChecker = _config$output.disableTsChecker,
|
|
17
|
+
enableCssModuleTSDeclaration = _config$output.enableCssModuleTSDeclaration,
|
|
18
|
+
enableInlineScripts = _config$output.enableInlineScripts,
|
|
19
|
+
enableInlineStyles = _config$output.enableInlineStyles,
|
|
20
|
+
polyfill = _config$output.polyfill,
|
|
21
|
+
dataUriLimit = _config$output.dataUriLimit,
|
|
22
|
+
disableAssetsCache = _config$output.disableAssetsCache,
|
|
23
|
+
enableLatestDecorators = _config$output.enableLatestDecorators,
|
|
24
|
+
disableCssModuleExtension = _config$output.disableCssModuleExtension,
|
|
25
|
+
ssg = _config$output.ssg,
|
|
26
|
+
enableModernMode = _config$output.enableModernMode,
|
|
27
|
+
disableNodePolyfill = _config$output.disableNodePolyfill;
|
|
28
|
+
return {
|
|
29
|
+
assetPrefix: assetPrefix,
|
|
30
|
+
copy: copy,
|
|
31
|
+
distPath: {
|
|
32
|
+
root: path,
|
|
33
|
+
css: cssPath,
|
|
34
|
+
js: jsPath,
|
|
35
|
+
html: htmlPath,
|
|
36
|
+
// `@modern-js/webpack` output all media files to `dist/media` by default
|
|
37
|
+
svg: mediaPath || 'media',
|
|
38
|
+
image: mediaPath || 'media',
|
|
39
|
+
font: mediaPath || 'media',
|
|
40
|
+
media: mediaPath || 'media'
|
|
41
|
+
},
|
|
42
|
+
dataUriLimit: {
|
|
43
|
+
svg: dataUriLimit,
|
|
44
|
+
image: dataUriLimit,
|
|
45
|
+
font: dataUriLimit,
|
|
46
|
+
media: dataUriLimit
|
|
47
|
+
},
|
|
48
|
+
disableCssExtract: disableCssExtract,
|
|
49
|
+
disableCssModuleExtension: disableCssModuleExtension,
|
|
50
|
+
disableInlineRuntimeChunk: disableInlineRuntimeChunk,
|
|
51
|
+
disableMinimize: disableMinimize,
|
|
52
|
+
disableSourceMap: disableSourceMap,
|
|
53
|
+
disableTsChecker: disableTsChecker || enableTsLoader,
|
|
54
|
+
enableCssModuleTSDeclaration: enableCssModuleTSDeclaration,
|
|
55
|
+
enableInlineScripts: enableInlineScripts,
|
|
56
|
+
enableInlineStyles: enableInlineStyles,
|
|
57
|
+
polyfill: polyfill,
|
|
58
|
+
disableFilenameHash: disableAssetsCache,
|
|
59
|
+
enableLatestDecorators: enableLatestDecorators,
|
|
60
|
+
filename: {
|
|
61
|
+
css: cssModuleLocalIdentName
|
|
62
|
+
},
|
|
63
|
+
ssg: ssg,
|
|
64
|
+
// set `true`, only in legacy config
|
|
65
|
+
enableAssetFallback: true,
|
|
66
|
+
enableAssetManifest: true,
|
|
67
|
+
enableModernMode: enableModernMode,
|
|
68
|
+
disableNodePolyfill: disableNodePolyfill
|
|
69
|
+
};
|
|
70
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
2
|
+
export function createSourceConfig(config) {
|
|
3
|
+
var _config$source = config.source,
|
|
4
|
+
alias = _config$source.alias,
|
|
5
|
+
envVars = _config$source.envVars,
|
|
6
|
+
globalVars = _config$source.globalVars,
|
|
7
|
+
include = _config$source.include,
|
|
8
|
+
moduleScopes = _config$source.moduleScopes,
|
|
9
|
+
preEntry = _config$source.preEntry,
|
|
10
|
+
entries = _config$source.entries,
|
|
11
|
+
enableAsyncEntry = _config$source.enableAsyncEntry,
|
|
12
|
+
disableDefaultEntries = _config$source.disableDefaultEntries,
|
|
13
|
+
entriesDir = _config$source.entriesDir,
|
|
14
|
+
configDir = _config$source.configDir;
|
|
15
|
+
var builderGlobalVars = globalVars || {};
|
|
16
|
+
var _iterator = _createForOfIteratorHelper(envVars || []),
|
|
17
|
+
_step;
|
|
18
|
+
try {
|
|
19
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
20
|
+
var envVar = _step.value;
|
|
21
|
+
var envVarValue = process.env[envVar];
|
|
22
|
+
envVarValue && (builderGlobalVars["process.env.".concat(envVar)] = envVarValue);
|
|
23
|
+
}
|
|
24
|
+
} catch (err) {
|
|
25
|
+
_iterator.e(err);
|
|
26
|
+
} finally {
|
|
27
|
+
_iterator.f();
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
alias: alias,
|
|
31
|
+
moduleScopes: moduleScopes,
|
|
32
|
+
globalVars: builderGlobalVars,
|
|
33
|
+
include: include,
|
|
34
|
+
preEntry: preEntry,
|
|
35
|
+
entries: entries,
|
|
36
|
+
enableAsyncEntry: enableAsyncEntry,
|
|
37
|
+
disableDefaultEntries: disableDefaultEntries,
|
|
38
|
+
entriesDir: entriesDir,
|
|
39
|
+
configDir: configDir
|
|
40
|
+
};
|
|
41
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export function createToolsConfig(config) {
|
|
2
|
+
var _config$tools = config.tools,
|
|
3
|
+
autoprefixer = _config$tools.autoprefixer,
|
|
4
|
+
babel = _config$tools.babel,
|
|
5
|
+
minifyCss = _config$tools.minifyCss,
|
|
6
|
+
terser = _config$tools.terser,
|
|
7
|
+
webpack = _config$tools.webpack,
|
|
8
|
+
webpackChain = _config$tools.webpackChain,
|
|
9
|
+
tsLoader = _config$tools.tsLoader,
|
|
10
|
+
styledComponents = _config$tools.styledComponents,
|
|
11
|
+
sass = _config$tools.sass,
|
|
12
|
+
postcss = _config$tools.postcss,
|
|
13
|
+
less = _config$tools.less,
|
|
14
|
+
htmlPlugin = _config$tools.htmlPlugin,
|
|
15
|
+
devServer = _config$tools.devServer,
|
|
16
|
+
tailwindcss = _config$tools.tailwindcss,
|
|
17
|
+
jest = _config$tools.jest,
|
|
18
|
+
esbuild = _config$tools.esbuild;
|
|
19
|
+
var enableTsLoader = config.output.enableTsLoader;
|
|
20
|
+
return {
|
|
21
|
+
tsLoader: enableTsLoader ? tsLoader : undefined,
|
|
22
|
+
autoprefixer: autoprefixer,
|
|
23
|
+
babel: babel,
|
|
24
|
+
minifyCss: minifyCss,
|
|
25
|
+
terser: terser,
|
|
26
|
+
webpack: webpack,
|
|
27
|
+
webpackChain: webpackChain,
|
|
28
|
+
styledComponents: styledComponents,
|
|
29
|
+
sass: sass,
|
|
30
|
+
postcss: postcss,
|
|
31
|
+
less: less,
|
|
32
|
+
htmlPlugin: htmlPlugin,
|
|
33
|
+
devServer: devServer,
|
|
34
|
+
tailwindcss: tailwindcss,
|
|
35
|
+
jest: jest,
|
|
36
|
+
esbuild: esbuild
|
|
37
|
+
};
|
|
38
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { initHtmlConfig, initSourceConfig, initToolsConfig } from "./inits";
|
|
2
|
+
export { transformNormalizedConfig } from "./transformNormalizedConfig";
|
|
3
|
+
export function checkIsLegacyConfig(config) {
|
|
4
|
+
return Boolean(config.legacy);
|
|
5
|
+
}
|
|
6
|
+
export function initialNormalizedConfig(config, appContext) {
|
|
7
|
+
initHtmlConfig(config, appContext);
|
|
8
|
+
initSourceConfig(config, appContext);
|
|
9
|
+
initToolsConfig(config);
|
|
10
|
+
return config;
|
|
11
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
2
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
4
|
+
import path, { dirname, isAbsolute, posix, sep } from 'path';
|
|
5
|
+
import { applyOptionsChain, findExists, findMonorepoRoot, globby, isModernjsMonorepo } from '@modern-js/utils';
|
|
6
|
+
export function initHtmlConfig(config, appContext) {
|
|
7
|
+
var ICON_EXTENSIONS = ['png', 'jpg', 'jpeg', 'svg', 'ico'];
|
|
8
|
+
config.html.appIcon = createBuilderAppIcon(config, appContext);
|
|
9
|
+
config.html.favicon = createBuilderFavicon(config, appContext);
|
|
10
|
+
return config.html;
|
|
11
|
+
function createBuilderAppIcon(config, appContext) {
|
|
12
|
+
var configDir = config.source.configDir;
|
|
13
|
+
var appIcon = findExists(ICON_EXTENSIONS.map(function (ext) {
|
|
14
|
+
return path.resolve(appContext.appDirectory, configDir || './config', "icon.".concat(ext));
|
|
15
|
+
}));
|
|
16
|
+
return typeof appIcon === 'string' ? appIcon : undefined;
|
|
17
|
+
}
|
|
18
|
+
function createBuilderFavicon(config, appContext) {
|
|
19
|
+
var configDir = config.source.configDir;
|
|
20
|
+
var favicon = config.html.favicon;
|
|
21
|
+
var defaultFavicon = findExists(ICON_EXTENSIONS.map(function (ext) {
|
|
22
|
+
return path.resolve(appContext.appDirectory, configDir || './config', "favicon.".concat(ext));
|
|
23
|
+
}));
|
|
24
|
+
return favicon || defaultFavicon || undefined;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export function initSourceConfig(config, appContext) {
|
|
28
|
+
config.source.include = createBuilderInclude(config, appContext);
|
|
29
|
+
config.source.moduleScopes = createBuilderModuleScope(config);
|
|
30
|
+
function createBuilderInclude(config, appContext) {
|
|
31
|
+
var include = config.source.include;
|
|
32
|
+
var defaultInclude = [appContext.internalDirectory];
|
|
33
|
+
var transformInclude = (include || []).map(function (include) {
|
|
34
|
+
if (typeof include === 'string') {
|
|
35
|
+
if (isAbsolute(include)) {
|
|
36
|
+
return include;
|
|
37
|
+
}
|
|
38
|
+
return new RegExp(include);
|
|
39
|
+
}
|
|
40
|
+
return include;
|
|
41
|
+
}).concat(defaultInclude); // concat default Include
|
|
42
|
+
|
|
43
|
+
var root = findMonorepoRoot(appContext.appDirectory);
|
|
44
|
+
if (!root) {
|
|
45
|
+
return transformInclude;
|
|
46
|
+
}
|
|
47
|
+
var modernjsMonorepo = isModernjsMonorepo(root);
|
|
48
|
+
if (modernjsMonorepo) {
|
|
49
|
+
var paths = globby.sync(posix.join(root, 'features', '**', 'package.json'), {
|
|
50
|
+
ignore: ['**/node_modules/**/*']
|
|
51
|
+
}).map(function (pathname) {
|
|
52
|
+
return dirname(pathname) + sep;
|
|
53
|
+
});
|
|
54
|
+
return [].concat(_toConsumableArray(paths), _toConsumableArray(transformInclude));
|
|
55
|
+
}
|
|
56
|
+
return transformInclude;
|
|
57
|
+
}
|
|
58
|
+
function createBuilderModuleScope(config) {
|
|
59
|
+
var moduleScopes = config.source.moduleScopes;
|
|
60
|
+
if (moduleScopes) {
|
|
61
|
+
var builderModuleScope = [];
|
|
62
|
+
var DEFAULT_SCOPES = ['./src', './shared', /node_modules/];
|
|
63
|
+
if (Array.isArray(moduleScopes)) {
|
|
64
|
+
if (isPrimitiveScope(moduleScopes)) {
|
|
65
|
+
builderModuleScope = DEFAULT_SCOPES.concat(moduleScopes);
|
|
66
|
+
} else {
|
|
67
|
+
builderModuleScope = [DEFAULT_SCOPES].concat(_toConsumableArray(moduleScopes));
|
|
68
|
+
}
|
|
69
|
+
} else {
|
|
70
|
+
builderModuleScope = [DEFAULT_SCOPES, moduleScopes];
|
|
71
|
+
}
|
|
72
|
+
return builderModuleScope;
|
|
73
|
+
} else {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
function isPrimitiveScope(items) {
|
|
77
|
+
return items.every(function (item) {
|
|
78
|
+
return typeof item === 'string' || Object.prototype.toString.call(item) === '[object RegExp]';
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
export function initToolsConfig(config) {
|
|
84
|
+
var defaultTsChecker = {
|
|
85
|
+
issue: {
|
|
86
|
+
include: [{
|
|
87
|
+
file: '**/src/**/*'
|
|
88
|
+
}],
|
|
89
|
+
exclude: [{
|
|
90
|
+
file: '**/*.(spec|test).ts'
|
|
91
|
+
}, {
|
|
92
|
+
file: '**/node_modules/**/*'
|
|
93
|
+
}]
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
var _config$tools = config.tools,
|
|
97
|
+
tsChecker = _config$tools.tsChecker,
|
|
98
|
+
tsLoader = _config$tools.tsLoader,
|
|
99
|
+
htmlPlugin = _config$tools.htmlPlugin;
|
|
100
|
+
config.tools.tsChecker = applyOptionsChain(defaultTsChecker, tsChecker);
|
|
101
|
+
tsLoader && (config.tools.tsLoader = function (tsLoaderConfig, utils) {
|
|
102
|
+
applyOptionsChain(_objectSpread(_objectSpread({}, tsLoaderConfig), {}, {
|
|
103
|
+
transpileOnly: false,
|
|
104
|
+
allowTsInNodeModules: true
|
|
105
|
+
}), tsLoader || {}, utils);
|
|
106
|
+
});
|
|
107
|
+
config.tools.htmlPlugin = [function (config) {
|
|
108
|
+
return _objectSpread(_objectSpread({}, config), {}, {
|
|
109
|
+
minify: _typeof(config.minify) === 'object' ? _objectSpread(_objectSpread({}, config.minify), {}, {
|
|
110
|
+
removeComments: false
|
|
111
|
+
}) : config.minify
|
|
112
|
+
});
|
|
113
|
+
}].concat(_toConsumableArray(Array.isArray(htmlPlugin) ? htmlPlugin : htmlPlugin ? [htmlPlugin] : []));
|
|
114
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { createToolsConfig } from "./createToolsConfig";
|
|
2
|
+
import { createSourceConfig } from "./createSourceConfig";
|
|
3
|
+
import { createOutputConfig } from "./createOutputConfig";
|
|
4
|
+
import { createHtmlConfig } from "./createHtmlConfig";
|
|
5
|
+
export function transformNormalizedConfig(config) {
|
|
6
|
+
var html = createHtmlConfig(config);
|
|
7
|
+
var output = createOutputConfig(config);
|
|
8
|
+
var source = createSourceConfig(config);
|
|
9
|
+
var tools = createToolsConfig(config);
|
|
10
|
+
var bff = config.bff,
|
|
11
|
+
dev = config.dev,
|
|
12
|
+
deploy = config.deploy,
|
|
13
|
+
runtime = config.runtime,
|
|
14
|
+
runtimeByEntries = config.runtimeByEntries,
|
|
15
|
+
server = config.server,
|
|
16
|
+
cliOptions = config.cliOptions,
|
|
17
|
+
plugins = config.plugins,
|
|
18
|
+
testing = config.testing;
|
|
19
|
+
return {
|
|
20
|
+
source: source,
|
|
21
|
+
html: html,
|
|
22
|
+
output: output,
|
|
23
|
+
tools: tools,
|
|
24
|
+
bff: bff,
|
|
25
|
+
dev: dev,
|
|
26
|
+
deploy: deploy,
|
|
27
|
+
runtime: runtime,
|
|
28
|
+
runtimeByEntries: runtimeByEntries,
|
|
29
|
+
server: server,
|
|
30
|
+
cliOptions: cliOptions,
|
|
31
|
+
testing: testing,
|
|
32
|
+
plugins: plugins,
|
|
33
|
+
security: {},
|
|
34
|
+
_raw: {},
|
|
35
|
+
experiments: {},
|
|
36
|
+
performance: {}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
export var defineConfig = function defineConfig(config) {
|
|
3
|
+
return config;
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated
|
|
8
|
+
* Using defineConfig first.
|
|
9
|
+
*/
|
|
10
|
+
export var defineLegacyConfig = function defineLegacyConfig(config) {
|
|
11
|
+
return _objectSpread(_objectSpread({}, config), {}, {
|
|
12
|
+
legacy: true
|
|
13
|
+
});
|
|
14
|
+
};
|
|
@@ -1,21 +1,25 @@
|
|
|
1
|
-
import { createAsyncWaterfall, createAsyncWorkflow } from '@modern-js/plugin';
|
|
2
|
-
export var beforeDev = createAsyncWorkflow();
|
|
3
|
-
export var afterDev = createAsyncWorkflow();
|
|
4
|
-
export var beforeCreateCompiler = createAsyncWorkflow();
|
|
5
|
-
export var afterCreateCompiler = createAsyncWorkflow();
|
|
6
|
-
export var beforePrintInstructions = createAsyncWaterfall();
|
|
7
|
-
export var beforeBuild = createAsyncWorkflow();
|
|
8
|
-
export var afterBuild = createAsyncWorkflow();
|
|
9
|
-
export var beforeDeploy = createAsyncWorkflow();
|
|
10
|
-
export var afterDeploy = createAsyncWorkflow();
|
|
1
|
+
import { createAsyncWaterfall, createAsyncWorkflow, createParallelWorkflow } from '@modern-js/plugin';
|
|
11
2
|
export var hooks = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
3
|
+
modifyEntryExport: createAsyncWaterfall(),
|
|
4
|
+
modifyEntryImports: createAsyncWaterfall(),
|
|
5
|
+
modifyEntryRuntimePlugins: createAsyncWaterfall(),
|
|
6
|
+
modifyEntryRenderFunction: createAsyncWaterfall(),
|
|
7
|
+
modifyAsyncEntry: createAsyncWaterfall(),
|
|
8
|
+
modifyFileSystemRoutes: createAsyncWaterfall(),
|
|
9
|
+
modifyServerRoutes: createAsyncWaterfall(),
|
|
10
|
+
htmlPartials: createAsyncWaterfall(),
|
|
11
|
+
beforeGenerateRoutes: createAsyncWaterfall(),
|
|
12
|
+
addDefineTypes: createAsyncWaterfall(),
|
|
13
|
+
beforeDev: createAsyncWorkflow(),
|
|
14
|
+
afterDev: createAsyncWorkflow(),
|
|
15
|
+
beforeCreateCompiler: createAsyncWorkflow(),
|
|
16
|
+
afterCreateCompiler: createAsyncWorkflow(),
|
|
17
|
+
beforePrintInstructions: createAsyncWaterfall(),
|
|
18
|
+
beforeBuild: createAsyncWorkflow(),
|
|
19
|
+
afterBuild: createAsyncWorkflow(),
|
|
20
|
+
beforeDeploy: createAsyncWorkflow(),
|
|
21
|
+
afterDeploy: createAsyncWorkflow(),
|
|
22
|
+
watchFiles: createParallelWorkflow(),
|
|
23
|
+
fileChange: createAsyncWorkflow(),
|
|
24
|
+
beforeRestart: createAsyncWorkflow()
|
|
21
25
|
};
|
|
@@ -2,22 +2,24 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
|
2
2
|
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
3
3
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
4
4
|
import path from 'path';
|
|
5
|
-
import { defineConfig, cli } from '@modern-js/core';
|
|
6
5
|
import LintPlugin from '@modern-js/plugin-lint';
|
|
7
6
|
import { cleanRequireCache, emptyDir, Import } from '@modern-js/utils';
|
|
8
7
|
import AnalyzePlugin from "./analyze";
|
|
8
|
+
import InitializePlugin from "./initialize";
|
|
9
9
|
import { hooks } from "./hooks";
|
|
10
10
|
import { i18n, localeKeys } from "./locale";
|
|
11
11
|
import { getLocaleLanguage } from "./utils/language";
|
|
12
12
|
import { getCommand } from "./utils/commands";
|
|
13
|
-
|
|
13
|
+
import { restart } from "./utils/restart";
|
|
14
|
+
export * from "./defineConfig";
|
|
15
|
+
export * from "./types";
|
|
14
16
|
var upgradeModel = Import.lazy('@modern-js/upgrade', require);
|
|
15
17
|
export default (function () {
|
|
16
18
|
return {
|
|
17
19
|
name: '@modern-js/app-tools',
|
|
18
|
-
post: ['@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'],
|
|
20
|
+
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'],
|
|
19
21
|
registerHook: hooks,
|
|
20
|
-
usePlugins: [AnalyzePlugin(), LintPlugin()],
|
|
22
|
+
usePlugins: [InitializePlugin(), AnalyzePlugin(), LintPlugin()],
|
|
21
23
|
setup: function setup(api) {
|
|
22
24
|
var locale = getLocaleLanguage();
|
|
23
25
|
i18n.changeLanguage({
|
|
@@ -237,7 +239,7 @@ export default (function () {
|
|
|
237
239
|
return closeServer();
|
|
238
240
|
case 11:
|
|
239
241
|
_context8.next = 13;
|
|
240
|
-
return
|
|
242
|
+
return restart(api.useHookRunners());
|
|
241
243
|
case 13:
|
|
242
244
|
case "end":
|
|
243
245
|
return _context8.stop();
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
2
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
4
|
+
import { ensureAbsolutePath, getPort, isDev } from '@modern-js/utils';
|
|
5
|
+
import { legacySchema, schema } from "../schema";
|
|
6
|
+
import { getCommand } from "../utils/commands";
|
|
7
|
+
import { transformNormalizedConfig } from "../config/initial/transformNormalizedConfig";
|
|
8
|
+
import { checkIsLegacyConfig, createDefaultConfig, createLegacyDefaultConfig } from "../config";
|
|
9
|
+
export default (function () {
|
|
10
|
+
return {
|
|
11
|
+
name: '@modern-js/plugin-initialize',
|
|
12
|
+
setup: function setup(api) {
|
|
13
|
+
var config = function config() {
|
|
14
|
+
var appContext = api.useAppContext();
|
|
15
|
+
var userConfig = api.useConfigContext();
|
|
16
|
+
return checkIsLegacyConfig(userConfig) ? createLegacyDefaultConfig(appContext) : createDefaultConfig(appContext);
|
|
17
|
+
};
|
|
18
|
+
var validateSchema = function validateSchema() {
|
|
19
|
+
var userConfig = api.useConfigContext();
|
|
20
|
+
var schemas = checkIsLegacyConfig(userConfig) ? legacySchema : schema;
|
|
21
|
+
return schemas.generate();
|
|
22
|
+
};
|
|
23
|
+
return {
|
|
24
|
+
config: config,
|
|
25
|
+
validateSchema: validateSchema,
|
|
26
|
+
resolvedConfig: function resolvedConfig(_ref) {
|
|
27
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
28
|
+
var _resolved$output$dist, _normalizedConfig$ser;
|
|
29
|
+
var resolved, appContext, userConfig, port, normalizedConfig;
|
|
30
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
31
|
+
while (1) {
|
|
32
|
+
switch (_context.prev = _context.next) {
|
|
33
|
+
case 0:
|
|
34
|
+
resolved = _ref.resolved;
|
|
35
|
+
appContext = api.useAppContext();
|
|
36
|
+
userConfig = api.useConfigContext();
|
|
37
|
+
_context.next = 5;
|
|
38
|
+
return getDevServerPort(appContext, resolved);
|
|
39
|
+
case 5:
|
|
40
|
+
port = _context.sent;
|
|
41
|
+
appContext = _objectSpread(_objectSpread({}, appContext), {}, {
|
|
42
|
+
port: port,
|
|
43
|
+
distDirectory: ensureAbsolutePath(appContext.distDirectory, ((_resolved$output$dist = resolved.output.distPath) === null || _resolved$output$dist === void 0 ? void 0 : _resolved$output$dist.root) || 'dist')
|
|
44
|
+
});
|
|
45
|
+
api.setAppContext(appContext);
|
|
46
|
+
normalizedConfig = checkIsLegacyConfig(resolved) ? transformNormalizedConfig(resolved) : resolved;
|
|
47
|
+
return _context.abrupt("return", {
|
|
48
|
+
resolved: {
|
|
49
|
+
// FIXME: the userConfig mayby legacy userConfig
|
|
50
|
+
_raw: userConfig,
|
|
51
|
+
source: normalizedConfig.source || {},
|
|
52
|
+
server: _objectSpread(_objectSpread({}, normalizedConfig.server || {}), {}, {
|
|
53
|
+
port: port || ((_normalizedConfig$ser = normalizedConfig.server) === null || _normalizedConfig$ser === void 0 ? void 0 : _normalizedConfig$ser.port)
|
|
54
|
+
}),
|
|
55
|
+
bff: normalizedConfig.bff || {},
|
|
56
|
+
dev: normalizedConfig.dev || {},
|
|
57
|
+
html: normalizedConfig.html || {},
|
|
58
|
+
output: normalizedConfig.output || {},
|
|
59
|
+
security: normalizedConfig.security || {},
|
|
60
|
+
tools: normalizedConfig.tools || {},
|
|
61
|
+
testing: normalizedConfig.testing || {},
|
|
62
|
+
plugins: normalizedConfig.plugins || [],
|
|
63
|
+
runtime: normalizedConfig.runtime || {},
|
|
64
|
+
runtimeByEntries: normalizedConfig.runtimeByEntries || {},
|
|
65
|
+
deploy: normalizedConfig.deploy || {},
|
|
66
|
+
performance: normalizedConfig.performance || {},
|
|
67
|
+
experiments: normalizedConfig.experiments || {}
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
case 10:
|
|
71
|
+
case "end":
|
|
72
|
+
return _context.stop();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}, _callee);
|
|
76
|
+
}))();
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
function getDevServerPort(_x, _x2) {
|
|
83
|
+
return _getDevServerPort.apply(this, arguments);
|
|
84
|
+
}
|
|
85
|
+
function _getDevServerPort() {
|
|
86
|
+
_getDevServerPort = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(appContext, resolved) {
|
|
87
|
+
var command, _appContext$port;
|
|
88
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
89
|
+
while (1) {
|
|
90
|
+
switch (_context2.prev = _context2.next) {
|
|
91
|
+
case 0:
|
|
92
|
+
command = getCommand();
|
|
93
|
+
if (!(isDev() && command === 'dev')) {
|
|
94
|
+
_context2.next = 10;
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
if (!(((_appContext$port = appContext.port) !== null && _appContext$port !== void 0 ? _appContext$port : 0) > 0)) {
|
|
98
|
+
_context2.next = 6;
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
_context2.t0 = appContext.port;
|
|
102
|
+
_context2.next = 9;
|
|
103
|
+
break;
|
|
104
|
+
case 6:
|
|
105
|
+
_context2.next = 8;
|
|
106
|
+
return getPort(resolved.server.port || 8080);
|
|
107
|
+
case 8:
|
|
108
|
+
_context2.t0 = _context2.sent;
|
|
109
|
+
case 9:
|
|
110
|
+
return _context2.abrupt("return", _context2.t0);
|
|
111
|
+
case 10:
|
|
112
|
+
return _context2.abrupt("return", resolved.server.port);
|
|
113
|
+
case 11:
|
|
114
|
+
case "end":
|
|
115
|
+
return _context2.stop();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}, _callee2);
|
|
119
|
+
}));
|
|
120
|
+
return _getDevServerPort.apply(this, arguments);
|
|
121
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
+
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
5
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
6
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
7
|
+
import _wrapNativeSuper from "@babel/runtime/helpers/esm/wrapNativeSuper";
|
|
8
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
9
|
+
import { merge } from '@modern-js/utils/lodash';
|
|
10
|
+
export var Schema = /*#__PURE__*/function (_Map) {
|
|
11
|
+
_inherits(Schema, _Map);
|
|
12
|
+
var _super = _createSuper(Schema);
|
|
13
|
+
function Schema() {
|
|
14
|
+
var _this;
|
|
15
|
+
var baseSchema = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
16
|
+
_classCallCheck(this, Schema);
|
|
17
|
+
_this = _super.call(this);
|
|
18
|
+
_defineProperty(_assertThisInitialized(_this), "schema", void 0);
|
|
19
|
+
_this.schema = baseSchema;
|
|
20
|
+
return _this;
|
|
21
|
+
}
|
|
22
|
+
_createClass(Schema, [{
|
|
23
|
+
key: "setSchema",
|
|
24
|
+
value: function setSchema(key, object) {
|
|
25
|
+
var _this2 = this;
|
|
26
|
+
Object.entries(object).forEach(function (_ref) {
|
|
27
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
28
|
+
k = _ref2[0],
|
|
29
|
+
v = _ref2[1];
|
|
30
|
+
var target = "".concat(key, ".").concat(k);
|
|
31
|
+
_this2.set(target, v);
|
|
32
|
+
});
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
}, {
|
|
36
|
+
key: "set",
|
|
37
|
+
value: function set(key, value) {
|
|
38
|
+
if (this.has(key)) {
|
|
39
|
+
merge(this.schema[key], value);
|
|
40
|
+
} else {
|
|
41
|
+
this.schema[key] = value;
|
|
42
|
+
}
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
}, {
|
|
46
|
+
key: "has",
|
|
47
|
+
value: function has(key) {
|
|
48
|
+
return key in this.schema;
|
|
49
|
+
}
|
|
50
|
+
}, {
|
|
51
|
+
key: "get",
|
|
52
|
+
value: function get(key) {
|
|
53
|
+
return this.schema[key];
|
|
54
|
+
}
|
|
55
|
+
}, {
|
|
56
|
+
key: "delete",
|
|
57
|
+
value: function _delete(key) {
|
|
58
|
+
return delete this.schema[key];
|
|
59
|
+
}
|
|
60
|
+
}, {
|
|
61
|
+
key: "generate",
|
|
62
|
+
value: function generate() {
|
|
63
|
+
return Object.entries(this.schema).map(function (_ref3) {
|
|
64
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
65
|
+
target = _ref4[0],
|
|
66
|
+
schema = _ref4[1];
|
|
67
|
+
return {
|
|
68
|
+
target: target,
|
|
69
|
+
schema: schema
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}]);
|
|
74
|
+
return Schema;
|
|
75
|
+
}( /*#__PURE__*/_wrapNativeSuper(Map));
|