@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,206 @@
|
|
|
1
|
+
export function createDefaultConfig(appContext) {
|
|
2
|
+
const defaultAlias = appContext ? {
|
|
3
|
+
[appContext.internalDirAlias]: appContext.internalDirectory,
|
|
4
|
+
[appContext.internalSrcAlias]: appContext.srcDirectory,
|
|
5
|
+
'@': appContext.srcDirectory,
|
|
6
|
+
'@shared': appContext.sharedDirectory
|
|
7
|
+
} : {};
|
|
8
|
+
const source = {
|
|
9
|
+
entries: undefined,
|
|
10
|
+
enableAsyncEntry: false,
|
|
11
|
+
disableDefaultEntries: false,
|
|
12
|
+
entriesDir: './src',
|
|
13
|
+
configDir: './config',
|
|
14
|
+
globalVars: undefined,
|
|
15
|
+
moduleScopes: undefined,
|
|
16
|
+
include: [],
|
|
17
|
+
alias: defaultAlias
|
|
18
|
+
};
|
|
19
|
+
const output = {
|
|
20
|
+
assetPrefix: '/',
|
|
21
|
+
distPath: {
|
|
22
|
+
html: 'html',
|
|
23
|
+
js: 'static/js',
|
|
24
|
+
css: 'static/css',
|
|
25
|
+
media: 'static/media',
|
|
26
|
+
root: 'dist'
|
|
27
|
+
},
|
|
28
|
+
copy: undefined,
|
|
29
|
+
disableCssModuleExtension: false,
|
|
30
|
+
enableCssModuleTSDeclaration: false,
|
|
31
|
+
disableMinimize: false,
|
|
32
|
+
enableInlineStyles: false,
|
|
33
|
+
enableInlineScripts: false,
|
|
34
|
+
disableSourceMap: false,
|
|
35
|
+
disableInlineRuntimeChunk: false,
|
|
36
|
+
disableFilenameHash: false,
|
|
37
|
+
enableLatestDecorators: false,
|
|
38
|
+
polyfill: 'entry',
|
|
39
|
+
cssModuleLocalIdentName: undefined
|
|
40
|
+
};
|
|
41
|
+
const html = {
|
|
42
|
+
title: '',
|
|
43
|
+
titleByEntries: undefined,
|
|
44
|
+
meta: {
|
|
45
|
+
charset: {
|
|
46
|
+
charset: 'utf-8'
|
|
47
|
+
},
|
|
48
|
+
viewport: 'width=device-width, initial-scale=1.0, shrink-to-fit=no, viewport-fit=cover, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no',
|
|
49
|
+
'http-equiv': {
|
|
50
|
+
'http-equiv': 'x-ua-compatible',
|
|
51
|
+
content: 'ie=edge'
|
|
52
|
+
},
|
|
53
|
+
renderer: 'webkit',
|
|
54
|
+
layoutmode: 'standard',
|
|
55
|
+
imagemode: 'force',
|
|
56
|
+
'wap-font-scale': 'no',
|
|
57
|
+
'format-detection': 'telephone=no'
|
|
58
|
+
},
|
|
59
|
+
metaByEntries: undefined,
|
|
60
|
+
inject: 'head',
|
|
61
|
+
injectByEntries: undefined,
|
|
62
|
+
mountId: 'root',
|
|
63
|
+
favicon: '',
|
|
64
|
+
faviconByEntries: undefined,
|
|
65
|
+
disableHtmlFolder: false,
|
|
66
|
+
templateParameters: {},
|
|
67
|
+
templateParametersByEntries: undefined
|
|
68
|
+
};
|
|
69
|
+
const server = {
|
|
70
|
+
routes: undefined,
|
|
71
|
+
publicRoutes: undefined,
|
|
72
|
+
ssr: undefined,
|
|
73
|
+
ssrByEntries: undefined,
|
|
74
|
+
baseUrl: '/',
|
|
75
|
+
port: 8080
|
|
76
|
+
};
|
|
77
|
+
const dev = {
|
|
78
|
+
assetPrefix: false,
|
|
79
|
+
https: false
|
|
80
|
+
};
|
|
81
|
+
const tools = {
|
|
82
|
+
webpack: undefined,
|
|
83
|
+
babel: undefined,
|
|
84
|
+
postcss: undefined,
|
|
85
|
+
autoprefixer: undefined,
|
|
86
|
+
devServer: undefined,
|
|
87
|
+
tsLoader: undefined,
|
|
88
|
+
terser: undefined,
|
|
89
|
+
minifyCss: undefined
|
|
90
|
+
};
|
|
91
|
+
return {
|
|
92
|
+
source,
|
|
93
|
+
output,
|
|
94
|
+
server,
|
|
95
|
+
dev,
|
|
96
|
+
html,
|
|
97
|
+
tools,
|
|
98
|
+
plugins: [],
|
|
99
|
+
runtime: {},
|
|
100
|
+
runtimeByEntries: {}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
export function createLegacyDefaultConfig(appContext) {
|
|
104
|
+
const defaultAlias = appContext ? {
|
|
105
|
+
[appContext.internalDirAlias]: appContext.internalDirectory,
|
|
106
|
+
[appContext.internalSrcAlias]: appContext.srcDirectory,
|
|
107
|
+
'@': appContext.srcDirectory,
|
|
108
|
+
'@shared': appContext.sharedDirectory
|
|
109
|
+
} : {};
|
|
110
|
+
const sourceDefaults = {
|
|
111
|
+
entries: undefined,
|
|
112
|
+
enableAsyncEntry: false,
|
|
113
|
+
disableDefaultEntries: false,
|
|
114
|
+
entriesDir: './src',
|
|
115
|
+
configDir: './config',
|
|
116
|
+
apiDir: './api',
|
|
117
|
+
envVars: [],
|
|
118
|
+
globalVars: undefined,
|
|
119
|
+
alias: defaultAlias,
|
|
120
|
+
moduleScopes: undefined,
|
|
121
|
+
include: []
|
|
122
|
+
};
|
|
123
|
+
const outputDefaults = {
|
|
124
|
+
assetPrefix: '/',
|
|
125
|
+
htmlPath: 'html',
|
|
126
|
+
jsPath: 'static/js',
|
|
127
|
+
cssPath: 'static/css',
|
|
128
|
+
mediaPath: 'static/media',
|
|
129
|
+
path: 'dist',
|
|
130
|
+
title: '',
|
|
131
|
+
titleByEntries: undefined,
|
|
132
|
+
meta: {
|
|
133
|
+
charset: {
|
|
134
|
+
charset: 'utf-8'
|
|
135
|
+
},
|
|
136
|
+
viewport: 'width=device-width, initial-scale=1.0, shrink-to-fit=no, viewport-fit=cover, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no',
|
|
137
|
+
'http-equiv': {
|
|
138
|
+
'http-equiv': 'x-ua-compatible',
|
|
139
|
+
content: 'ie=edge'
|
|
140
|
+
},
|
|
141
|
+
renderer: 'webkit',
|
|
142
|
+
layoutmode: 'standard',
|
|
143
|
+
imagemode: 'force',
|
|
144
|
+
'wap-font-scale': 'no',
|
|
145
|
+
'format-detection': 'telephone=no'
|
|
146
|
+
},
|
|
147
|
+
metaByEntries: undefined,
|
|
148
|
+
inject: 'head',
|
|
149
|
+
injectByEntries: undefined,
|
|
150
|
+
mountId: 'root',
|
|
151
|
+
favicon: '',
|
|
152
|
+
faviconByEntries: undefined,
|
|
153
|
+
copy: undefined,
|
|
154
|
+
disableHtmlFolder: false,
|
|
155
|
+
disableCssModuleExtension: false,
|
|
156
|
+
disableCssExtract: false,
|
|
157
|
+
enableCssModuleTSDeclaration: false,
|
|
158
|
+
disableMinimize: false,
|
|
159
|
+
enableInlineStyles: false,
|
|
160
|
+
enableInlineScripts: false,
|
|
161
|
+
disableSourceMap: false,
|
|
162
|
+
disableInlineRuntimeChunk: false,
|
|
163
|
+
disableAssetsCache: false,
|
|
164
|
+
enableLatestDecorators: false,
|
|
165
|
+
polyfill: 'entry',
|
|
166
|
+
dataUriLimit: 10000,
|
|
167
|
+
templateParameters: {},
|
|
168
|
+
templateParametersByEntries: undefined,
|
|
169
|
+
cssModuleLocalIdentName: undefined,
|
|
170
|
+
enableModernMode: false,
|
|
171
|
+
disableNodePolyfill: false,
|
|
172
|
+
enableTsLoader: false
|
|
173
|
+
};
|
|
174
|
+
const serverDefaults = {
|
|
175
|
+
routes: undefined,
|
|
176
|
+
publicRoutes: undefined,
|
|
177
|
+
ssr: undefined,
|
|
178
|
+
ssrByEntries: undefined,
|
|
179
|
+
baseUrl: '/',
|
|
180
|
+
port: 8080
|
|
181
|
+
};
|
|
182
|
+
const devDefaults = {
|
|
183
|
+
assetPrefix: false,
|
|
184
|
+
https: false
|
|
185
|
+
};
|
|
186
|
+
const toolsDefaults = {
|
|
187
|
+
webpack: undefined,
|
|
188
|
+
babel: undefined,
|
|
189
|
+
postcss: undefined,
|
|
190
|
+
autoprefixer: undefined,
|
|
191
|
+
lodash: undefined,
|
|
192
|
+
devServer: undefined,
|
|
193
|
+
tsLoader: undefined,
|
|
194
|
+
terser: undefined,
|
|
195
|
+
minifyCss: undefined
|
|
196
|
+
};
|
|
197
|
+
return {
|
|
198
|
+
source: sourceDefaults,
|
|
199
|
+
output: outputDefaults,
|
|
200
|
+
server: serverDefaults,
|
|
201
|
+
dev: devDefaults,
|
|
202
|
+
tools: toolsDefaults,
|
|
203
|
+
runtime: {},
|
|
204
|
+
runtimeByEntries: {}
|
|
205
|
+
};
|
|
206
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export function createHtmlConfig(config) {
|
|
2
|
+
const {
|
|
3
|
+
disableHtmlFolder,
|
|
4
|
+
favicon,
|
|
5
|
+
faviconByEntries,
|
|
6
|
+
inject,
|
|
7
|
+
injectByEntries,
|
|
8
|
+
meta,
|
|
9
|
+
metaByEntries,
|
|
10
|
+
mountId,
|
|
11
|
+
title,
|
|
12
|
+
titleByEntries,
|
|
13
|
+
templateParameters,
|
|
14
|
+
templateParametersByEntries,
|
|
15
|
+
crossorigin
|
|
16
|
+
} = config.output;
|
|
17
|
+
return {
|
|
18
|
+
disableHtmlFolder,
|
|
19
|
+
favicon,
|
|
20
|
+
faviconByEntries,
|
|
21
|
+
inject,
|
|
22
|
+
injectByEntries,
|
|
23
|
+
meta,
|
|
24
|
+
metaByEntries,
|
|
25
|
+
mountId,
|
|
26
|
+
title,
|
|
27
|
+
titleByEntries,
|
|
28
|
+
crossorigin,
|
|
29
|
+
templateParameters,
|
|
30
|
+
templateParametersByEntries
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export function createOutputConfig(normalizedConfig, appContext) {
|
|
3
|
-
// TODO: add `externals` options in Modern.
|
|
4
|
-
|
|
1
|
+
export function createOutputConfig(config) {
|
|
5
2
|
const {
|
|
6
3
|
assetPrefix,
|
|
7
4
|
copy,
|
|
@@ -10,8 +7,10 @@ export function createOutputConfig(normalizedConfig, appContext) {
|
|
|
10
7
|
jsPath,
|
|
11
8
|
htmlPath,
|
|
12
9
|
mediaPath,
|
|
10
|
+
enableTsLoader,
|
|
13
11
|
path,
|
|
14
12
|
disableInlineRuntimeChunk,
|
|
13
|
+
disableCssExtract,
|
|
15
14
|
disableMinimize,
|
|
16
15
|
disableSourceMap,
|
|
17
16
|
disableTsChecker,
|
|
@@ -22,13 +21,14 @@ export function createOutputConfig(normalizedConfig, appContext) {
|
|
|
22
21
|
dataUriLimit,
|
|
23
22
|
disableAssetsCache,
|
|
24
23
|
enableLatestDecorators,
|
|
25
|
-
disableCssModuleExtension
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
disableCssModuleExtension,
|
|
25
|
+
ssg,
|
|
26
|
+
enableModernMode,
|
|
27
|
+
disableNodePolyfill
|
|
28
|
+
} = config.output;
|
|
29
29
|
return {
|
|
30
30
|
assetPrefix,
|
|
31
|
-
copy
|
|
31
|
+
copy,
|
|
32
32
|
distPath: {
|
|
33
33
|
root: path,
|
|
34
34
|
css: cssPath,
|
|
@@ -46,25 +46,26 @@ export function createOutputConfig(normalizedConfig, appContext) {
|
|
|
46
46
|
font: dataUriLimit,
|
|
47
47
|
media: dataUriLimit
|
|
48
48
|
},
|
|
49
|
+
disableCssExtract,
|
|
49
50
|
disableCssModuleExtension,
|
|
50
51
|
disableInlineRuntimeChunk,
|
|
51
52
|
disableMinimize,
|
|
52
53
|
disableSourceMap,
|
|
53
|
-
disableTsChecker,
|
|
54
|
+
disableTsChecker: disableTsChecker || enableTsLoader,
|
|
54
55
|
enableCssModuleTSDeclaration,
|
|
55
56
|
enableInlineScripts,
|
|
56
57
|
enableInlineStyles,
|
|
57
58
|
polyfill,
|
|
58
|
-
// 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
|
|
59
|
-
cleanDistPath: false,
|
|
60
59
|
disableFilenameHash: disableAssetsCache,
|
|
61
60
|
enableLatestDecorators,
|
|
62
61
|
filename: {
|
|
63
62
|
css: cssModuleLocalIdentName
|
|
64
63
|
},
|
|
65
|
-
|
|
64
|
+
ssg,
|
|
65
|
+
// set `true`, only in legacy config
|
|
66
|
+
enableAssetFallback: true,
|
|
66
67
|
enableAssetManifest: true,
|
|
67
|
-
|
|
68
|
-
|
|
68
|
+
enableModernMode,
|
|
69
|
+
disableNodePolyfill
|
|
69
70
|
};
|
|
70
71
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export function createSourceConfig(config) {
|
|
2
|
+
const {
|
|
3
|
+
alias,
|
|
4
|
+
envVars,
|
|
5
|
+
globalVars,
|
|
6
|
+
include,
|
|
7
|
+
moduleScopes,
|
|
8
|
+
preEntry,
|
|
9
|
+
entries,
|
|
10
|
+
enableAsyncEntry,
|
|
11
|
+
disableDefaultEntries,
|
|
12
|
+
entriesDir,
|
|
13
|
+
configDir
|
|
14
|
+
} = config.source;
|
|
15
|
+
const builderGlobalVars = globalVars || {};
|
|
16
|
+
for (const envVar of envVars || []) {
|
|
17
|
+
const envVarValue = process.env[envVar];
|
|
18
|
+
envVarValue && (builderGlobalVars[`process.env.${envVar}`] = envVarValue);
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
alias,
|
|
22
|
+
moduleScopes,
|
|
23
|
+
globalVars: builderGlobalVars,
|
|
24
|
+
include,
|
|
25
|
+
preEntry,
|
|
26
|
+
entries,
|
|
27
|
+
enableAsyncEntry,
|
|
28
|
+
disableDefaultEntries,
|
|
29
|
+
entriesDir,
|
|
30
|
+
configDir
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export function createToolsConfig(config) {
|
|
2
|
+
const {
|
|
3
|
+
autoprefixer,
|
|
4
|
+
babel,
|
|
5
|
+
minifyCss,
|
|
6
|
+
terser,
|
|
7
|
+
webpack,
|
|
8
|
+
webpackChain,
|
|
9
|
+
tsLoader,
|
|
10
|
+
styledComponents,
|
|
11
|
+
sass,
|
|
12
|
+
postcss,
|
|
13
|
+
less,
|
|
14
|
+
htmlPlugin,
|
|
15
|
+
devServer,
|
|
16
|
+
tailwindcss,
|
|
17
|
+
jest,
|
|
18
|
+
esbuild
|
|
19
|
+
} = config.tools;
|
|
20
|
+
const {
|
|
21
|
+
enableTsLoader
|
|
22
|
+
} = config.output;
|
|
23
|
+
return {
|
|
24
|
+
tsLoader: enableTsLoader ? tsLoader : undefined,
|
|
25
|
+
autoprefixer,
|
|
26
|
+
babel,
|
|
27
|
+
minifyCss,
|
|
28
|
+
terser,
|
|
29
|
+
webpack,
|
|
30
|
+
webpackChain,
|
|
31
|
+
styledComponents,
|
|
32
|
+
sass,
|
|
33
|
+
postcss,
|
|
34
|
+
less,
|
|
35
|
+
htmlPlugin,
|
|
36
|
+
devServer,
|
|
37
|
+
tailwindcss,
|
|
38
|
+
jest,
|
|
39
|
+
esbuild
|
|
40
|
+
};
|
|
41
|
+
}
|
|
@@ -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,117 @@
|
|
|
1
|
+
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; }
|
|
2
|
+
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; }
|
|
3
|
+
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; }
|
|
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
|
+
const 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
|
+
const {
|
|
13
|
+
configDir
|
|
14
|
+
} = config.source;
|
|
15
|
+
const appIcon = findExists(ICON_EXTENSIONS.map(ext => path.resolve(appContext.appDirectory, configDir || './config', `icon.${ext}`)));
|
|
16
|
+
return typeof appIcon === 'string' ? appIcon : undefined;
|
|
17
|
+
}
|
|
18
|
+
function createBuilderFavicon(config, appContext) {
|
|
19
|
+
const {
|
|
20
|
+
configDir
|
|
21
|
+
} = config.source;
|
|
22
|
+
const {
|
|
23
|
+
favicon
|
|
24
|
+
} = config.html;
|
|
25
|
+
const defaultFavicon = findExists(ICON_EXTENSIONS.map(ext => path.resolve(appContext.appDirectory, configDir || './config', `favicon.${ext}`)));
|
|
26
|
+
return favicon || defaultFavicon || undefined;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export function initSourceConfig(config, appContext) {
|
|
30
|
+
config.source.include = createBuilderInclude(config, appContext);
|
|
31
|
+
config.source.moduleScopes = createBuilderModuleScope(config);
|
|
32
|
+
function createBuilderInclude(config, appContext) {
|
|
33
|
+
const {
|
|
34
|
+
include
|
|
35
|
+
} = config.source;
|
|
36
|
+
const defaultInclude = [appContext.internalDirectory];
|
|
37
|
+
const transformInclude = (include || []).map(include => {
|
|
38
|
+
if (typeof include === 'string') {
|
|
39
|
+
if (isAbsolute(include)) {
|
|
40
|
+
return include;
|
|
41
|
+
}
|
|
42
|
+
return new RegExp(include);
|
|
43
|
+
}
|
|
44
|
+
return include;
|
|
45
|
+
}).concat(defaultInclude); // concat default Include
|
|
46
|
+
|
|
47
|
+
const root = findMonorepoRoot(appContext.appDirectory);
|
|
48
|
+
if (!root) {
|
|
49
|
+
return transformInclude;
|
|
50
|
+
}
|
|
51
|
+
const modernjsMonorepo = isModernjsMonorepo(root);
|
|
52
|
+
if (modernjsMonorepo) {
|
|
53
|
+
const paths = globby.sync(posix.join(root, 'features', '**', 'package.json'), {
|
|
54
|
+
ignore: ['**/node_modules/**/*']
|
|
55
|
+
}).map(pathname => dirname(pathname) + sep);
|
|
56
|
+
return [...paths, ...transformInclude];
|
|
57
|
+
}
|
|
58
|
+
return transformInclude;
|
|
59
|
+
}
|
|
60
|
+
function createBuilderModuleScope(config) {
|
|
61
|
+
const {
|
|
62
|
+
moduleScopes
|
|
63
|
+
} = config.source;
|
|
64
|
+
if (moduleScopes) {
|
|
65
|
+
let builderModuleScope = [];
|
|
66
|
+
const DEFAULT_SCOPES = ['./src', './shared', /node_modules/];
|
|
67
|
+
if (Array.isArray(moduleScopes)) {
|
|
68
|
+
if (isPrimitiveScope(moduleScopes)) {
|
|
69
|
+
builderModuleScope = DEFAULT_SCOPES.concat(moduleScopes);
|
|
70
|
+
} else {
|
|
71
|
+
builderModuleScope = [DEFAULT_SCOPES, ...moduleScopes];
|
|
72
|
+
}
|
|
73
|
+
} else {
|
|
74
|
+
builderModuleScope = [DEFAULT_SCOPES, moduleScopes];
|
|
75
|
+
}
|
|
76
|
+
return builderModuleScope;
|
|
77
|
+
} else {
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
function isPrimitiveScope(items) {
|
|
81
|
+
return items.every(item => typeof item === 'string' || Object.prototype.toString.call(item) === '[object RegExp]');
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
export function initToolsConfig(config) {
|
|
86
|
+
const defaultTsChecker = {
|
|
87
|
+
issue: {
|
|
88
|
+
include: [{
|
|
89
|
+
file: '**/src/**/*'
|
|
90
|
+
}],
|
|
91
|
+
exclude: [{
|
|
92
|
+
file: '**/*.(spec|test).ts'
|
|
93
|
+
}, {
|
|
94
|
+
file: '**/node_modules/**/*'
|
|
95
|
+
}]
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
const {
|
|
99
|
+
tsChecker,
|
|
100
|
+
tsLoader,
|
|
101
|
+
htmlPlugin
|
|
102
|
+
} = config.tools;
|
|
103
|
+
config.tools.tsChecker = applyOptionsChain(defaultTsChecker, tsChecker);
|
|
104
|
+
tsLoader && (config.tools.tsLoader = (tsLoaderConfig, utils) => {
|
|
105
|
+
applyOptionsChain(_objectSpread(_objectSpread({}, tsLoaderConfig), {}, {
|
|
106
|
+
transpileOnly: false,
|
|
107
|
+
allowTsInNodeModules: true
|
|
108
|
+
}), tsLoader || {}, utils);
|
|
109
|
+
});
|
|
110
|
+
config.tools.htmlPlugin = [config => _objectSpread(_objectSpread({}, config), {}, {
|
|
111
|
+
minify: typeof config.minify === 'object' ? _objectSpread(_objectSpread({}, config.minify), {}, {
|
|
112
|
+
removeComments: false
|
|
113
|
+
}) : config.minify
|
|
114
|
+
}),
|
|
115
|
+
// eslint-disable-next-line no-nested-ternary
|
|
116
|
+
...(Array.isArray(htmlPlugin) ? htmlPlugin : htmlPlugin ? [htmlPlugin] : [])];
|
|
117
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
const html = createHtmlConfig(config);
|
|
7
|
+
const output = createOutputConfig(config);
|
|
8
|
+
const source = createSourceConfig(config);
|
|
9
|
+
const tools = createToolsConfig(config);
|
|
10
|
+
const {
|
|
11
|
+
bff,
|
|
12
|
+
dev,
|
|
13
|
+
deploy,
|
|
14
|
+
runtime,
|
|
15
|
+
runtimeByEntries,
|
|
16
|
+
server,
|
|
17
|
+
cliOptions,
|
|
18
|
+
plugins,
|
|
19
|
+
testing
|
|
20
|
+
} = config;
|
|
21
|
+
return {
|
|
22
|
+
source,
|
|
23
|
+
html,
|
|
24
|
+
output,
|
|
25
|
+
tools,
|
|
26
|
+
bff,
|
|
27
|
+
dev,
|
|
28
|
+
deploy,
|
|
29
|
+
runtime,
|
|
30
|
+
runtimeByEntries,
|
|
31
|
+
server,
|
|
32
|
+
cliOptions,
|
|
33
|
+
testing,
|
|
34
|
+
plugins: plugins,
|
|
35
|
+
security: {},
|
|
36
|
+
_raw: {},
|
|
37
|
+
experiments: {},
|
|
38
|
+
performance: {}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
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; }
|
|
2
|
+
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; }
|
|
3
|
+
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; }
|
|
4
|
+
export const defineConfig = config => config;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated
|
|
8
|
+
* Using defineConfig first.
|
|
9
|
+
*/
|
|
10
|
+
export const defineLegacyConfig = config => _objectSpread(_objectSpread({}, config), {}, {
|
|
11
|
+
legacy: true
|
|
12
|
+
});
|
package/dist/js/modern/hooks.js
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
|
-
import { createAsyncWaterfall, createAsyncWorkflow } from '@modern-js/plugin';
|
|
2
|
-
export const beforeDev = createAsyncWorkflow();
|
|
3
|
-
export const afterDev = createAsyncWorkflow();
|
|
4
|
-
export const beforeCreateCompiler = createAsyncWorkflow();
|
|
5
|
-
export const afterCreateCompiler = createAsyncWorkflow();
|
|
6
|
-
export const beforePrintInstructions = createAsyncWaterfall();
|
|
7
|
-
export const beforeBuild = createAsyncWorkflow();
|
|
8
|
-
export const afterBuild = createAsyncWorkflow();
|
|
9
|
-
export const beforeDeploy = createAsyncWorkflow();
|
|
10
|
-
export const afterDeploy = createAsyncWorkflow();
|
|
1
|
+
import { createAsyncWaterfall, createAsyncWorkflow, createParallelWorkflow } from '@modern-js/plugin';
|
|
11
2
|
export const 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
|
};
|
package/dist/js/modern/index.js
CHANGED
|
@@ -2,21 +2,23 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
2
2
|
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; }
|
|
3
3
|
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; }
|
|
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
|
const upgradeModel = Import.lazy('@modern-js/upgrade', require);
|
|
15
17
|
export default (() => ({
|
|
16
18
|
name: '@modern-js/app-tools',
|
|
17
|
-
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'],
|
|
19
|
+
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'],
|
|
18
20
|
registerHook: hooks,
|
|
19
|
-
usePlugins: [AnalyzePlugin(), LintPlugin()],
|
|
21
|
+
usePlugins: [InitializePlugin(), AnalyzePlugin(), LintPlugin()],
|
|
20
22
|
setup: api => {
|
|
21
23
|
const locale = getLocaleLanguage();
|
|
22
24
|
i18n.changeLanguage({
|
|
@@ -99,7 +101,7 @@ export default (() => ({
|
|
|
99
101
|
closeServer
|
|
100
102
|
} = await import("./utils/createServer");
|
|
101
103
|
await closeServer();
|
|
102
|
-
await
|
|
104
|
+
await restart(api.useHookRunners());
|
|
103
105
|
}
|
|
104
106
|
},
|
|
105
107
|
async beforeRestart() {
|