@modern-js/app-tools 2.0.0-beta.1 → 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 +194 -0
- package/dist/js/modern/analyze/generateCode.js +1 -1
- 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 +10 -6
- package/dist/js/modern/analyze/index.js +12 -27
- package/dist/js/modern/builder/builderPlugins/compatModern.js +12 -11
- package/dist/js/modern/builder/index.js +33 -16
- 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 +18 -9
- package/dist/js/modern/commands/inspect.js +4 -2
- package/dist/js/modern/commands/start.js +1 -0
- 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 +14 -16
- 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/generateCode.js +1 -1
- 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 +10 -6
- package/dist/js/node/analyze/index.js +13 -39
- package/dist/js/node/builder/builderPlugins/compatModern.js +12 -11
- package/dist/js/node/builder/index.js +34 -16
- 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 +18 -9
- package/dist/js/node/commands/inspect.js +4 -2
- package/dist/js/node/commands/start.js +1 -0
- 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 +14 -16
- 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 +90 -0
- package/dist/js/node/utils/restart.js +23 -0
- package/dist/js/treeshaking/analyze/generateCode.js +1 -1
- 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 +8 -7
- package/dist/js/treeshaking/analyze/index.js +10 -26
- package/dist/js/treeshaking/builder/builderPlugins/compatModern.js +12 -11
- package/dist/js/treeshaking/builder/index.js +31 -16
- 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 +36 -22
- package/dist/js/treeshaking/commands/inspect.js +8 -3
- package/dist/js/treeshaking/commands/start.js +1 -0
- 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 +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/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 +1 -1
- package/dist/types/analyze/utils.d.ts +1 -1
- package/dist/types/builder/builderPlugins/compatModern.d.ts +2 -2
- package/dist/types/builder/index.d.ts +5 -2
- 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 +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 -2
- 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 +24 -24
- 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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,199 @@
|
|
|
1
1
|
# @modern-js/app-tools
|
|
2
2
|
|
|
3
|
+
## 2.0.0-beta.2
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- dda38c9c3e: chore: v2
|
|
8
|
+
|
|
9
|
+
### Minor Changes
|
|
10
|
+
|
|
11
|
+
- edd1cfb1af: feat: modernjs Access builder compiler
|
|
12
|
+
feat: modernjs 接入 builder 构建
|
|
13
|
+
- 543be9558e: feat: compile server loader and support handle loader request
|
|
14
|
+
feat: 编译 server loader 并支持处理 loader 的请求
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- c9f912ca4d: feat(app-tools): improve build logs of dev and build command
|
|
19
|
+
|
|
20
|
+
feat(app-tools): 优化 dev 和 build 过程中的日志展示
|
|
21
|
+
|
|
22
|
+
- 103973cde9: fix: builder tools.webpackChain config args not match the Modernjs tools.webpackChain
|
|
23
|
+
fix: builder tools.webpackChain 配置传参无法匹配 Modernjs tools.webpackChain
|
|
24
|
+
- 0b2d1ef02b: fix: repeat register `babel-plugin-lodash`
|
|
25
|
+
fix: 重复注册 `babel-plugin-lodash`
|
|
26
|
+
- 82cef85ed7: fix: specify builder compiler framework
|
|
27
|
+
fix: 指明 builder 构建时框架
|
|
28
|
+
- 3e57f2b: feat: add document feature with plugin
|
|
29
|
+
|
|
30
|
+
feat: 增加 document 功能插件
|
|
31
|
+
|
|
32
|
+
- 85edee888c: feat(app-tools): support tools.htmlPlugin config
|
|
33
|
+
|
|
34
|
+
feat(app-tools): 支持 tools.htmlPlugin 配置项
|
|
35
|
+
|
|
36
|
+
- 5402fdb: feat(Builder): add output.disableTsChecker config
|
|
37
|
+
|
|
38
|
+
feat(Builder): 新增 output.disableTsChecker 配置项
|
|
39
|
+
|
|
40
|
+
- dc8eeb9cbb: fix: clear distDirectory in prepare hook & inject data loader plugin to server
|
|
41
|
+
fix: 在 prepare hook 中清理 dist 目录,并且向 server 中注入 data loader plugin
|
|
42
|
+
- cc971eabfc: refactor: move server plugin load logic in `@modern-js/core`
|
|
43
|
+
refactor:移除在 `@modern-js/core` 中的 server 插件加载逻辑
|
|
44
|
+
- 5b9049f2e9: feat: inject async js chunk when streaming ssr
|
|
45
|
+
feat: streaming ssr 时, 注入 async 类型的 js chunk
|
|
46
|
+
- d4a4566: chore: rename plugin-jarvis to plugin-lint
|
|
47
|
+
|
|
48
|
+
chore: 重命名 plugin-jarvis 为 plugin-lint
|
|
49
|
+
|
|
50
|
+
- 6bda14ed71: feat: refactor router with react-router@6.4
|
|
51
|
+
|
|
52
|
+
feat: 使用 react-router@6.4 重构路由模块
|
|
53
|
+
|
|
54
|
+
- d36c6ee126: fix(app-tools): failed to run inspect command
|
|
55
|
+
|
|
56
|
+
fix(app-tools): 修复运行 inspect 命令失败的问题
|
|
57
|
+
|
|
58
|
+
- 92004d1: feat: support load chunks parallelly
|
|
59
|
+
feat: 支持并行加载 chunks
|
|
60
|
+
- b8bbe036c7: feat: change type logic
|
|
61
|
+
feat: 修改类型相关的逻辑
|
|
62
|
+
- 40ed587: feat: inject css chunk into html for streaming ssr
|
|
63
|
+
feat: streaming ssr 返回的 html 注入 css chunk
|
|
64
|
+
- af4422d67f: feat(builder): complete utils of tools.webpack
|
|
65
|
+
|
|
66
|
+
feat(builder): 补全 tools.webpack 提供的 utils 方法
|
|
67
|
+
|
|
68
|
+
- 87c1ff8: feat(app-tools): attach builder instance to appContext
|
|
69
|
+
|
|
70
|
+
feat(app-tools): 将 builder 实例挂载到 appContext 上
|
|
71
|
+
|
|
72
|
+
- c258e34202: fix: add builder hooks `beforeBuild` params
|
|
73
|
+
fix: 新增 builder hooks `beforeBuild` 的参数
|
|
74
|
+
- 3b3d709: fix(app-tools): cli --analyze option not work
|
|
75
|
+
|
|
76
|
+
fix(app-tools): 修复 --analyze 命令行参数不生效的问题
|
|
77
|
+
|
|
78
|
+
- 8b8e1bb571: feat: support nested routes
|
|
79
|
+
feat: 支持嵌套路由
|
|
80
|
+
- a2c8cc3: fix: change tools define userconfig type
|
|
81
|
+
fix: 修改工程定义的 UserConfig 类型
|
|
82
|
+
- 7de97ae: fix: `deploy` command has't load `builder` instance
|
|
83
|
+
fix: `deploy` 命令没有加载 builder 实例
|
|
84
|
+
- c3b7de4: fix(app-tools): dev.assetPrefix not work
|
|
85
|
+
|
|
86
|
+
fix(app-tools): 修复 dev.assetPrefix 配置项不生效的问题
|
|
87
|
+
|
|
88
|
+
- 92004d1: fix: use loadable lazy instead of loadable
|
|
89
|
+
fix: 使用 loadable lazy 组件替代 loadable
|
|
90
|
+
- c677befc22: fix(app-tools): compat legacy resolve behavior
|
|
91
|
+
|
|
92
|
+
fix(app-tools): 兼容旧版本 node_modules 解析逻辑
|
|
93
|
+
|
|
94
|
+
- 3f7cde5caa: fix: builder plugin setup can't get config
|
|
95
|
+
fix: builder 插件在 setup 阶段无法拿到 config
|
|
96
|
+
- 99213e4bae: fix: process does't exit when exec command
|
|
97
|
+
fix: 修复执行命令时进程未退出的问题
|
|
98
|
+
- b16fd964da: fix: `modern-js/app-tools` pass error config to builder.
|
|
99
|
+
fix: `modern-js/app-tools` 传递错误的 config 给 builder.
|
|
100
|
+
- 7eefedd7ca: fix: add html-webpack-plugin `__internal__` options, for bottom template
|
|
101
|
+
fix: 为了 bottom template, 增加 `html-webpack-plugin` `__internal__` 配置项,
|
|
102
|
+
- 14b712da84: fix: use consistent alias type and default value across packages
|
|
103
|
+
|
|
104
|
+
fix: 在各个包中使用一致的 alias 类型定义和默认值
|
|
105
|
+
|
|
106
|
+
- Updated dependencies [c9f912ca4d]
|
|
107
|
+
- Updated dependencies [95be7cc49c]
|
|
108
|
+
- Updated dependencies [e439457a51]
|
|
109
|
+
- Updated dependencies [4d1545f8c0]
|
|
110
|
+
- Updated dependencies [2bc090c089]
|
|
111
|
+
- Updated dependencies [f96a725211]
|
|
112
|
+
- Updated dependencies [828f42f9ce]
|
|
113
|
+
- Updated dependencies [060abd4]
|
|
114
|
+
- Updated dependencies [309cd71]
|
|
115
|
+
- Updated dependencies [c7456864a8]
|
|
116
|
+
- Updated dependencies [c9e800d39a]
|
|
117
|
+
- Updated dependencies [0ff846fb56]
|
|
118
|
+
- Updated dependencies [3cf9633]
|
|
119
|
+
- Updated dependencies [57077b2c64]
|
|
120
|
+
- Updated dependencies [d032d49]
|
|
121
|
+
- Updated dependencies [2ff6167]
|
|
122
|
+
- Updated dependencies [287f298990]
|
|
123
|
+
- Updated dependencies [15bf09d9c8]
|
|
124
|
+
- Updated dependencies [423188db70]
|
|
125
|
+
- Updated dependencies [fd2d652c03]
|
|
126
|
+
- Updated dependencies [0c2d8dae31]
|
|
127
|
+
- Updated dependencies [2edad29]
|
|
128
|
+
- Updated dependencies [85edee888c]
|
|
129
|
+
- Updated dependencies [a2509bfbdb]
|
|
130
|
+
- Updated dependencies [3998875791]
|
|
131
|
+
- Updated dependencies [ab3924a]
|
|
132
|
+
- Updated dependencies [3998875791]
|
|
133
|
+
- Updated dependencies [ba86b8b711]
|
|
134
|
+
- Updated dependencies [61f21d1e77]
|
|
135
|
+
- Updated dependencies [5402fdb]
|
|
136
|
+
- Updated dependencies [2ae58176fe]
|
|
137
|
+
- Updated dependencies [92f0ead]
|
|
138
|
+
- Updated dependencies [edd1cfb1af]
|
|
139
|
+
- Updated dependencies [5d67c26cdb]
|
|
140
|
+
- Updated dependencies [cc971eabfc]
|
|
141
|
+
- Updated dependencies [5b9049f2e9]
|
|
142
|
+
- Updated dependencies [d4a4566]
|
|
143
|
+
- Updated dependencies [18360a38d7]
|
|
144
|
+
- Updated dependencies [6bda14ed71]
|
|
145
|
+
- Updated dependencies [0b314e6946]
|
|
146
|
+
- Updated dependencies [92004d1]
|
|
147
|
+
- Updated dependencies [b8bbe036c7]
|
|
148
|
+
- Updated dependencies [5911154]
|
|
149
|
+
- Updated dependencies [40ed587]
|
|
150
|
+
- Updated dependencies [af4422d67f]
|
|
151
|
+
- Updated dependencies [705adc1]
|
|
152
|
+
- Updated dependencies [87c1ff8]
|
|
153
|
+
- Updated dependencies [d5a31df781]
|
|
154
|
+
- Updated dependencies [dda38c9c3e]
|
|
155
|
+
- Updated dependencies [102d32e4ba]
|
|
156
|
+
- Updated dependencies [c258e34202]
|
|
157
|
+
- Updated dependencies [812913c]
|
|
158
|
+
- Updated dependencies [7248342e4d]
|
|
159
|
+
- Updated dependencies [568eab1e42]
|
|
160
|
+
- Updated dependencies [8b8e1bb571]
|
|
161
|
+
- Updated dependencies [3bbea92b2a]
|
|
162
|
+
- Updated dependencies [ae71096d45]
|
|
163
|
+
- Updated dependencies [73cd29dd9f]
|
|
164
|
+
- Updated dependencies [a23010138d]
|
|
165
|
+
- Updated dependencies [75d1b2657c]
|
|
166
|
+
- Updated dependencies [18aaf42]
|
|
167
|
+
- Updated dependencies [f179749]
|
|
168
|
+
- Updated dependencies [3fae2d0]
|
|
169
|
+
- Updated dependencies [8a6d45f105]
|
|
170
|
+
- Updated dependencies [ebbeed1]
|
|
171
|
+
- Updated dependencies [90e2879520]
|
|
172
|
+
- Updated dependencies [df41d71]
|
|
173
|
+
- Updated dependencies [f727e5c6cc]
|
|
174
|
+
- Updated dependencies [5e3cecd523]
|
|
175
|
+
- Updated dependencies [abf3421a75]
|
|
176
|
+
- Updated dependencies [da2d1fc3c2]
|
|
177
|
+
- Updated dependencies [543be9558e]
|
|
178
|
+
- Updated dependencies [14b712da84]
|
|
179
|
+
- @modern-js/builder-webpack-provider@2.0.0-beta.2
|
|
180
|
+
- @modern-js/builder-shared@2.0.0-beta.2
|
|
181
|
+
- @modern-js/core@2.0.0-beta.2
|
|
182
|
+
- @modern-js/prod-server@2.0.0-beta.2
|
|
183
|
+
- @modern-js/builder-plugin-esbuild@2.0.0-beta.2
|
|
184
|
+
- @modern-js/server@2.0.0-beta.2
|
|
185
|
+
- @modern-js/node-bundle-require@2.0.0-beta.2
|
|
186
|
+
- @modern-js/utils@2.0.0-beta.2
|
|
187
|
+
- @modern-js/builder-plugin-node-polyfill@2.0.0-beta.2
|
|
188
|
+
- @modern-js/types@2.0.0-beta.2
|
|
189
|
+
- @modern-js/plugin-lint@2.0.0-beta.2
|
|
190
|
+
- @modern-js/plugin@2.0.0-beta.2
|
|
191
|
+
- @modern-js/builder@2.0.0-beta.2
|
|
192
|
+
- @modern-js/plugin-data-loader@2.0.0-beta.2
|
|
193
|
+
- @modern-js/plugin-i18n@2.0.0-beta.2
|
|
194
|
+
- @modern-js/new-action@2.0.0-beta.2
|
|
195
|
+
- @modern-js/upgrade@2.0.0-beta.2
|
|
196
|
+
|
|
3
197
|
## 2.0.0-beta.1
|
|
4
198
|
|
|
5
199
|
### Major Changes
|
|
@@ -113,7 +113,7 @@ export const generateCode = async (appContext, config, entrypoints, api) => {
|
|
|
113
113
|
const islegacy = Boolean(config === null || config === void 0 ? void 0 : (_config$runtime = config.runtime) === null || _config$runtime === void 0 ? void 0 : (_config$runtime$route = _config$runtime.router) === null || _config$runtime$route === void 0 ? void 0 : _config$runtime$route.legacy);
|
|
114
114
|
const {
|
|
115
115
|
mountId
|
|
116
|
-
} = config.
|
|
116
|
+
} = config.html;
|
|
117
117
|
const getRoutes = islegacy ? getClientRoutesLegacy : getClientRoutes;
|
|
118
118
|
await Promise.all(entrypoints.map(generateEntryCode));
|
|
119
119
|
async function generateEntryCode(entrypoint) {
|
|
@@ -56,7 +56,7 @@ export const getBundleEntry = (appContext, config) => {
|
|
|
56
56
|
}
|
|
57
57
|
if (!disableDefaultEntries) {
|
|
58
58
|
// find main entry point which server route is '/'.
|
|
59
|
-
const entriesDirAbs = ensureAbsolutePath(appDirectory, entriesDir);
|
|
59
|
+
const entriesDirAbs = ensureAbsolutePath(appDirectory, entriesDir || '');
|
|
60
60
|
const found = defaults.find(({
|
|
61
61
|
entryName,
|
|
62
62
|
entry,
|
|
@@ -67,7 +67,7 @@ export const getFileSystemEntry = (appContext, config) => {
|
|
|
67
67
|
entriesDir
|
|
68
68
|
}
|
|
69
69
|
} = config;
|
|
70
|
-
const src = ensureAbsolutePath(appDirectory, entriesDir);
|
|
70
|
+
const src = ensureAbsolutePath(appDirectory, entriesDir || '');
|
|
71
71
|
if (fs.existsSync(src)) {
|
|
72
72
|
if (fs.statSync(src).isDirectory()) {
|
|
73
73
|
return scanDir(isBundleEntry(src) ? [src] : fs.readdirSync(src).map(file => path.join(src, file)).filter(file => fs.statSync(file).isDirectory() && isBundleEntry(file)));
|
|
@@ -36,7 +36,7 @@ export const getHtmlTemplate = async (entrypoints, api, {
|
|
|
36
36
|
configDir
|
|
37
37
|
}
|
|
38
38
|
} = config;
|
|
39
|
-
const htmlDir = path.resolve(appDirectory, configDir, HTML_PARTIALS_FOLDER);
|
|
39
|
+
const htmlDir = path.resolve(appDirectory, configDir || '', HTML_PARTIALS_FOLDER);
|
|
40
40
|
const htmlTemplates = {};
|
|
41
41
|
for (const entrypoint of entrypoints) {
|
|
42
42
|
const {
|
|
@@ -94,10 +94,13 @@ const applyRouteOptions = (original, routeOptions) => {
|
|
|
94
94
|
*/
|
|
95
95
|
const collectHtmlRoutes = (entrypoints, appContext, config) => {
|
|
96
96
|
const {
|
|
97
|
+
html: {
|
|
98
|
+
disableHtmlFolder
|
|
99
|
+
},
|
|
97
100
|
output: {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
+
distPath: {
|
|
102
|
+
html: htmlPath
|
|
103
|
+
} = {}
|
|
101
104
|
},
|
|
102
105
|
server: {
|
|
103
106
|
baseUrl,
|
|
@@ -124,7 +127,8 @@ const collectHtmlRoutes = (entrypoints, appContext, config) => {
|
|
|
124
127
|
isSPA: true,
|
|
125
128
|
isSSR,
|
|
126
129
|
responseHeaders: resHeaders,
|
|
127
|
-
|
|
130
|
+
// FIXME: remove the config.enableModernMode
|
|
131
|
+
// enableModernMode: Boolean(enableModernMode),
|
|
128
132
|
bundle: isSSR ? `${SERVER_BUNDLE_DIRECTORY}/${entryName}.js` : undefined
|
|
129
133
|
};
|
|
130
134
|
if (routes !== null && routes !== void 0 && routes.hasOwnProperty(entryName)) {
|
|
@@ -157,14 +161,14 @@ const collectStaticRoutes = (appContext, config) => {
|
|
|
157
161
|
publicRoutes = {}
|
|
158
162
|
}
|
|
159
163
|
} = config;
|
|
160
|
-
const publicFolder = path.resolve(appDirectory, configDir, 'public');
|
|
164
|
+
const publicFolder = path.resolve(appDirectory, configDir || '', 'public');
|
|
161
165
|
return fs.existsSync(publicFolder) ? walkDirectory(publicFolder).map(filePath => {
|
|
162
166
|
const urlPath = `${urlJoin(toPosix(filePath).slice(toPosix(publicFolder).length))}`;
|
|
163
167
|
return {
|
|
164
168
|
urlPath: publicRoutes[removeLeadingSlash(urlPath)] || urlPath,
|
|
165
169
|
isSPA: true,
|
|
166
170
|
isSSR: false,
|
|
167
|
-
entryPath: toPosix(path.relative(path.resolve(appDirectory, configDir), filePath))
|
|
171
|
+
entryPath: toPosix(path.relative(path.resolve(appDirectory, configDir || ''), filePath))
|
|
168
172
|
};
|
|
169
173
|
}) : [];
|
|
170
174
|
};
|
|
@@ -2,7 +2,6 @@ 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 * as path from 'path';
|
|
5
|
-
import { createAsyncWaterfall } from '@modern-js/plugin';
|
|
6
5
|
import { createDebugger, fs, isApiOnly } from '@modern-js/utils';
|
|
7
6
|
import { cloneDeep } from '@modern-js/utils/lodash';
|
|
8
7
|
import { createBuilderForEdenX } from "../builder";
|
|
@@ -10,34 +9,11 @@ import { printInstructions } from "../utils/printInstructions";
|
|
|
10
9
|
import { generateRoutes } from "../utils/routes";
|
|
11
10
|
import { emitResolvedConfig } from "../utils/config";
|
|
12
11
|
import { getCommand } from "../utils/commands";
|
|
12
|
+
import { initialNormalizedConfig } from "../config";
|
|
13
13
|
import { isRouteComponentFile } from "./utils";
|
|
14
14
|
const debug = createDebugger('plugin-analyze');
|
|
15
|
-
export const modifyEntryImports = createAsyncWaterfall();
|
|
16
|
-
export const modifyEntryExport = createAsyncWaterfall();
|
|
17
|
-
export const addRuntimeExports = createAsyncWaterfall();
|
|
18
|
-
export const modifyEntryRuntimePlugins = createAsyncWaterfall();
|
|
19
|
-
export const modifyEntryRenderFunction = createAsyncWaterfall();
|
|
20
|
-
export const modifyAsyncEntry = createAsyncWaterfall();
|
|
21
|
-
export const modifyFileSystemRoutes = createAsyncWaterfall();
|
|
22
|
-
export const modifyServerRoutes = createAsyncWaterfall();
|
|
23
|
-
export const htmlPartials = createAsyncWaterfall();
|
|
24
|
-
export const beforeGenerateRoutes = createAsyncWaterfall();
|
|
25
|
-
export const addDefineTypes = createAsyncWaterfall();
|
|
26
15
|
export default (() => ({
|
|
27
16
|
name: '@modern-js/plugin-analyze',
|
|
28
|
-
registerHook: {
|
|
29
|
-
modifyAsyncEntry,
|
|
30
|
-
modifyEntryImports,
|
|
31
|
-
modifyEntryExport,
|
|
32
|
-
modifyEntryRuntimePlugins,
|
|
33
|
-
modifyEntryRenderFunction,
|
|
34
|
-
modifyFileSystemRoutes,
|
|
35
|
-
modifyServerRoutes,
|
|
36
|
-
htmlPartials,
|
|
37
|
-
addRuntimeExports,
|
|
38
|
-
beforeGenerateRoutes,
|
|
39
|
-
addDefineTypes
|
|
40
|
-
},
|
|
41
17
|
setup: api => {
|
|
42
18
|
let pagesDir = [];
|
|
43
19
|
let originEntrypoints = [];
|
|
@@ -52,7 +28,7 @@ export default (() => ({
|
|
|
52
28
|
} catch (_unused) {
|
|
53
29
|
// FIXME:
|
|
54
30
|
}
|
|
55
|
-
const apiOnly = await isApiOnly(appContext.appDirectory,
|
|
31
|
+
const apiOnly = await isApiOnly(appContext.appDirectory, (_resolvedConfig$sourc = resolvedConfig.source) === null || _resolvedConfig$sourc === void 0 ? void 0 : _resolvedConfig$sourc.entriesDir);
|
|
56
32
|
await hookRunners.addRuntimeExports();
|
|
57
33
|
if (apiOnly) {
|
|
58
34
|
const {
|
|
@@ -119,7 +95,7 @@ export default (() => ({
|
|
|
119
95
|
if (buildCommands.includes(command)) {
|
|
120
96
|
const normalizedConfig = api.useResolvedConfigContext();
|
|
121
97
|
const builder = await createBuilderForEdenX({
|
|
122
|
-
normalizedConfig,
|
|
98
|
+
normalizedConfig: normalizedConfig,
|
|
123
99
|
appContext,
|
|
124
100
|
compatPluginConfig: {
|
|
125
101
|
async onBeforeBuild({
|
|
@@ -180,6 +156,15 @@ export default (() => ({
|
|
|
180
156
|
watchFiles() {
|
|
181
157
|
return pagesDir;
|
|
182
158
|
},
|
|
159
|
+
resolvedConfig({
|
|
160
|
+
resolved
|
|
161
|
+
}) {
|
|
162
|
+
const appContext = api.useAppContext();
|
|
163
|
+
const config = initialNormalizedConfig(resolved, appContext);
|
|
164
|
+
return {
|
|
165
|
+
resolved: config
|
|
166
|
+
};
|
|
167
|
+
},
|
|
183
168
|
async fileChange(e) {
|
|
184
169
|
const appContext = api.useAppContext();
|
|
185
170
|
const {
|
|
@@ -62,14 +62,15 @@ export const PluginCompatModern = (appContext, modernConfig, options) => ({
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
// apply copy plugin
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
65
|
+
if (chain.plugins.has(CHAIN_ID.PLUGIN.COPY)) {
|
|
66
|
+
const defaultCopyPattern = createCopyPattern(appContext, modernConfig, 'public', chain);
|
|
67
|
+
chain.plugin(CHAIN_ID.PLUGIN.COPY).tap(args => {
|
|
68
|
+
var _args$;
|
|
69
|
+
return [{
|
|
70
|
+
patterns: [...(((_args$ = args[0]) === null || _args$ === void 0 ? void 0 : _args$.patterns) || []), defaultCopyPattern]
|
|
71
|
+
}];
|
|
72
|
+
});
|
|
73
|
+
}
|
|
73
74
|
const {
|
|
74
75
|
entrypoints
|
|
75
76
|
} = appContext;
|
|
@@ -167,9 +168,9 @@ function applyBottomHtmlWebpackPlugin({
|
|
|
167
168
|
// FIXME: the only need necessary
|
|
168
169
|
const baseTemplateParams = _objectSpread({
|
|
169
170
|
entryName,
|
|
170
|
-
title: getEntryOptions(entryName, modernConfig.
|
|
171
|
-
mountId: modernConfig.
|
|
172
|
-
}, getEntryOptions(entryName, modernConfig.
|
|
171
|
+
title: getEntryOptions(entryName, modernConfig.html.title, modernConfig.html.titleByEntries, appContext.packageName),
|
|
172
|
+
mountId: modernConfig.html.mountId
|
|
173
|
+
}, getEntryOptions(entryName, modernConfig.html.templateParameters, modernConfig.html.templateParametersByEntries, appContext.packageName));
|
|
173
174
|
chain.plugin(`${CHAIN_ID.PLUGIN.HTML}-${entryName}`).tap(args => [_objectSpread(_objectSpread({}, args[0] || {}), {}, {
|
|
174
175
|
__internal__: true,
|
|
175
176
|
bottomTemplate: appContext.htmlTemplates[`__${entryName}-bottom__`] && lodashTemplate(appContext.htmlTemplates[`__${entryName}-bottom__`])(baseTemplateParams)
|
|
@@ -1,11 +1,11 @@
|
|
|
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; }
|
|
1
4
|
import { createBuilder } from '@modern-js/builder';
|
|
2
5
|
import { builderWebpackProvider } from '@modern-js/builder-webpack-provider';
|
|
3
6
|
import { applyOptionsChain, isUseSSRBundle } from '@modern-js/utils';
|
|
4
7
|
import { PluginCompatModern } from "./builderPlugins/compatModern";
|
|
5
|
-
import {
|
|
6
|
-
import { createOutputConfig } from "./createOutputConfig";
|
|
7
|
-
import { createSourceConfig } from "./createSourceConfig";
|
|
8
|
-
import { createToolsConfig } from "./createToolsConfig";
|
|
8
|
+
import { createCopyPattern } from "./share";
|
|
9
9
|
function getBuilderTargets(normalizedConfig) {
|
|
10
10
|
const targets = ['web'];
|
|
11
11
|
if (normalizedConfig.output.enableModernMode && !targets.includes('modern-web')) {
|
|
@@ -21,8 +21,8 @@ export async function createBuilderForEdenX({
|
|
|
21
21
|
appContext,
|
|
22
22
|
compatPluginConfig
|
|
23
23
|
}) {
|
|
24
|
-
const builderConfig = createBuilderProviderConfig(normalizedConfig, appContext);
|
|
25
24
|
// create webpack provider
|
|
25
|
+
const builderConfig = createBuilderProviderConfig(normalizedConfig, appContext);
|
|
26
26
|
const webpackProvider = builderWebpackProvider({
|
|
27
27
|
builderConfig
|
|
28
28
|
});
|
|
@@ -32,25 +32,42 @@ export async function createBuilderForEdenX({
|
|
|
32
32
|
await applyBuilderPlugins(builder, normalizedConfig, appContext, compatPluginConfig);
|
|
33
33
|
return builder;
|
|
34
34
|
}
|
|
35
|
-
function createBuilderProviderConfig(normalizedConfig, appContext) {
|
|
36
|
-
const source = createSourceConfig(normalizedConfig, appContext);
|
|
37
|
-
const html = createHtmlConfig(normalizedConfig, appContext);
|
|
35
|
+
export function createBuilderProviderConfig(normalizedConfig, appContext) {
|
|
38
36
|
const output = createOutputConfig(normalizedConfig, appContext);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
return _objectSpread(_objectSpread({}, normalizedConfig), {}, {
|
|
38
|
+
source: _objectSpread(_objectSpread({}, normalizedConfig.source), {}, {
|
|
39
|
+
resolveExtensionPrefix: '.web'
|
|
40
|
+
}),
|
|
43
41
|
output,
|
|
44
|
-
tools,
|
|
45
42
|
dev: {
|
|
46
43
|
https: normalizedConfig.dev.https,
|
|
47
44
|
assetPrefix: normalizedConfig.dev.assetPrefix
|
|
48
45
|
},
|
|
49
|
-
|
|
46
|
+
html: _objectSpread(_objectSpread({}, normalizedConfig.html), {}, {
|
|
47
|
+
templateByEntries: normalizedConfig.html.templateByEntries || appContext.htmlTemplates
|
|
48
|
+
}),
|
|
49
|
+
performance: _objectSpread(_objectSpread({}, normalizedConfig.performance), {}, {
|
|
50
50
|
// `@modern-js/webpack` used to remove moment locale by default
|
|
51
51
|
removeMomentLocale: true
|
|
52
|
-
}
|
|
53
|
-
};
|
|
52
|
+
})
|
|
53
|
+
});
|
|
54
|
+
function createOutputConfig(config, appContext) {
|
|
55
|
+
const defaultCopyPattern = createCopyPattern(appContext, config, 'upload');
|
|
56
|
+
const {
|
|
57
|
+
copy
|
|
58
|
+
} = config.output;
|
|
59
|
+
const copyOptions = Array.isArray(copy) ? copy : copy === null || copy === void 0 ? void 0 : copy.patterns;
|
|
60
|
+
const builderCopy = [...(copyOptions || []), defaultCopyPattern];
|
|
61
|
+
return _objectSpread(_objectSpread({}, config.output), {}, {
|
|
62
|
+
copy: builderCopy,
|
|
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
|
+
// `@modern-js/webpack` used to generate asset manifest by default
|
|
66
|
+
enableAssetManifest: true,
|
|
67
|
+
// compatible the modern-js with fallback behavior
|
|
68
|
+
enableAssetFallback: true
|
|
69
|
+
});
|
|
70
|
+
}
|
|
54
71
|
}
|
|
55
72
|
export function createBuilderOptions(target, appContext) {
|
|
56
73
|
// create entries
|
|
@@ -2,7 +2,7 @@ import path from 'path';
|
|
|
2
2
|
import { template as lodashTemplate } from '@modern-js/utils/lodash';
|
|
3
3
|
import { removeTailSlash } from '@modern-js/utils';
|
|
4
4
|
export function createCopyPattern(appContext, config, patternsType, chain) {
|
|
5
|
-
const configDir = path.resolve(appContext.appDirectory, config.source.configDir);
|
|
5
|
+
const configDir = path.resolve(appContext.appDirectory, config.source.configDir || './config');
|
|
6
6
|
const uploadDir = path.posix.join(configDir.replace(/\\/g, '/'), 'upload');
|
|
7
7
|
const publicDir = path.posix.join(configDir.replace(/\\/g, '/'), 'public');
|
|
8
8
|
const minifiedJsRexExp = /\.min\.js/;
|
|
@@ -6,6 +6,10 @@ import { logger, printBuildError } from '@modern-js/utils';
|
|
|
6
6
|
import { generateRoutes } from "../utils/routes";
|
|
7
7
|
import { buildServerConfig } from "../utils/config";
|
|
8
8
|
export const build = async (api, options) => {
|
|
9
|
+
if (options !== null && options !== void 0 && options.analyze) {
|
|
10
|
+
// Builder will read this env var to enable bundle analyzer
|
|
11
|
+
process.env.BUNDLE_ANALYZE = 'true';
|
|
12
|
+
}
|
|
9
13
|
let resolvedConfig = api.useResolvedConfigContext();
|
|
10
14
|
const appContext = api.useAppContext();
|
|
11
15
|
const hookRunners = api.useHookRunners();
|
|
@@ -49,9 +53,11 @@ export const build = async (api, options) => {
|
|
|
49
53
|
configFile: serverConfigFile
|
|
50
54
|
});
|
|
51
55
|
try {
|
|
52
|
-
var _appContext$builder;
|
|
53
56
|
logger.info('Create a production build...\n');
|
|
54
|
-
|
|
57
|
+
if (!appContext.builder) {
|
|
58
|
+
throw new Error('Expect the Builder to have been initialized, But the appContext.builder received `undefined`');
|
|
59
|
+
}
|
|
60
|
+
await appContext.builder.build();
|
|
55
61
|
} catch (error) {
|
|
56
62
|
printBuildError(error);
|
|
57
63
|
// eslint-disable-next-line no-process-exit
|
|
@@ -3,19 +3,25 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
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 { logger } from '@modern-js/utils';
|
|
5
5
|
import { ResolvedConfigContext } from '@modern-js/core';
|
|
6
|
+
import { createFileWatcher } from "../utils/createFileWatcher";
|
|
6
7
|
import { printInstructions } from "../utils/printInstructions";
|
|
7
8
|
import { createServer, injectDataLoaderPlugin } from "../utils/createServer";
|
|
8
9
|
import { generateRoutes } from "../utils/routes";
|
|
9
10
|
import { getSpecifiedEntries } from "../utils/getSpecifiedEntries";
|
|
10
11
|
import { buildServerConfig } from "../utils/config";
|
|
11
12
|
export const dev = async (api, options) => {
|
|
12
|
-
|
|
13
|
+
var _normalizedConfig$too;
|
|
14
|
+
if (options.analyze) {
|
|
15
|
+
// Builder will read this env var to enable bundle analyzer
|
|
16
|
+
process.env.BUNDLE_ANALYZE = 'true';
|
|
17
|
+
}
|
|
18
|
+
let normalizedConfig = api.useResolvedConfigContext();
|
|
13
19
|
const appContext = api.useAppContext();
|
|
14
20
|
const hookRunners = api.useHookRunners();
|
|
15
|
-
|
|
21
|
+
normalizedConfig = _objectSpread(_objectSpread({}, normalizedConfig), {}, {
|
|
16
22
|
cliOptions: options
|
|
17
23
|
});
|
|
18
|
-
ResolvedConfigContext.set(
|
|
24
|
+
ResolvedConfigContext.set(normalizedConfig);
|
|
19
25
|
const {
|
|
20
26
|
appDirectory,
|
|
21
27
|
distDirectory,
|
|
@@ -43,8 +49,10 @@ export const dev = async (api, options) => {
|
|
|
43
49
|
await hookRunners.beforeDev();
|
|
44
50
|
let compiler = null;
|
|
45
51
|
if (!apiOnly) {
|
|
46
|
-
|
|
47
|
-
|
|
52
|
+
if (!appContext.builder) {
|
|
53
|
+
throw new Error('Expect the Builder to have been initialized, But the appContext.builder received `undefined`');
|
|
54
|
+
}
|
|
55
|
+
compiler = await appContext.builder.createCompiler();
|
|
48
56
|
}
|
|
49
57
|
await generateRoutes(appContext);
|
|
50
58
|
const app = await createServer({
|
|
@@ -58,11 +66,11 @@ export const dev = async (api, options) => {
|
|
|
58
66
|
hot: true,
|
|
59
67
|
liveReload: true,
|
|
60
68
|
port,
|
|
61
|
-
https:
|
|
62
|
-
}),
|
|
69
|
+
https: normalizedConfig.dev.https
|
|
70
|
+
}), (_normalizedConfig$too = normalizedConfig.tools) === null || _normalizedConfig$too === void 0 ? void 0 : _normalizedConfig$too.devServer),
|
|
63
71
|
compiler,
|
|
64
72
|
pwd: appDirectory,
|
|
65
|
-
config:
|
|
73
|
+
config: normalizedConfig,
|
|
66
74
|
serverConfigFile,
|
|
67
75
|
internalPlugins: injectDataLoaderPlugin(serverInternalPlugins)
|
|
68
76
|
});
|
|
@@ -73,7 +81,8 @@ export const dev = async (api, options) => {
|
|
|
73
81
|
if (!apiOnly) {
|
|
74
82
|
logger.info(`Starting dev server...\n`);
|
|
75
83
|
} else {
|
|
76
|
-
printInstructions(hookRunners, appContext,
|
|
84
|
+
printInstructions(hookRunners, appContext, normalizedConfig);
|
|
77
85
|
}
|
|
78
86
|
});
|
|
87
|
+
await createFileWatcher(appContext, normalizedConfig.source.configDir, hookRunners);
|
|
79
88
|
};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { join } from 'path';
|
|
2
2
|
export const inspect = async (api, options) => {
|
|
3
|
-
var _appContext$builder;
|
|
4
3
|
const appContext = api.useAppContext();
|
|
5
|
-
|
|
4
|
+
if (!appContext.builder) {
|
|
5
|
+
throw new Error('Expect the Builder to have been initialized, But the appContext.builder received `undefined`');
|
|
6
|
+
}
|
|
7
|
+
return appContext.builder.inspectConfig({
|
|
6
8
|
env: options.env,
|
|
7
9
|
verbose: options.verbose,
|
|
8
10
|
outputPath: join(appContext === null || appContext === void 0 ? void 0 : appContext.builder.context.distPath, options.output),
|
|
@@ -16,6 +16,7 @@ export const start = async api => {
|
|
|
16
16
|
const apiOnly = await isApiOnly(appContext.appDirectory, userConfig === null || userConfig === void 0 ? void 0 : (_userConfig$source = userConfig.source) === null || _userConfig$source === void 0 ? void 0 : _userConfig$source.entriesDir);
|
|
17
17
|
const app = await server({
|
|
18
18
|
pwd: appDirectory,
|
|
19
|
+
// FIXME: remove the `any` type
|
|
19
20
|
config: userConfig,
|
|
20
21
|
serverConfigFile,
|
|
21
22
|
internalPlugins: injectDataLoaderPlugin(appContext.serverInternalPlugins),
|