@modern-js/module-tools 2.0.0-beta.4 → 2.0.0-beta.7
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 +152 -0
- package/dist/build.d.ts +3 -0
- package/dist/build.js +73 -0
- package/dist/build.js.map +1 -0
- package/dist/builder/build.js +55 -51
- package/dist/builder/build.js.map +1 -1
- package/dist/builder/clear.js +17 -24
- package/dist/builder/clear.js.map +1 -1
- package/dist/builder/copy.d.ts +2 -0
- package/dist/builder/copy.js +45 -56
- package/dist/builder/copy.js.map +1 -1
- package/dist/builder/dts/index.js +8 -3
- package/dist/builder/dts/index.js.map +1 -1
- package/dist/builder/dts/rollup.js +39 -52
- package/dist/builder/dts/rollup.js.map +1 -1
- package/dist/builder/dts/tsc.js +28 -35
- package/dist/builder/dts/tsc.js.map +1 -1
- package/dist/builder/index.js +15 -31
- package/dist/builder/index.js.map +1 -1
- package/dist/builder/platform.js +74 -68
- package/dist/builder/platform.js.map +1 -1
- package/dist/cli.js +16 -24
- package/dist/cli.js.map +1 -1
- package/dist/command.js +47 -60
- package/dist/command.js.map +1 -1
- package/dist/config/defineConfig.js +7 -3
- package/dist/config/defineConfig.js.map +1 -1
- package/dist/config/normalize.js +32 -41
- package/dist/config/normalize.js.map +1 -1
- package/dist/config/schema.d.ts +4 -4
- package/dist/config/schema.js +12 -4
- package/dist/config/schema.js.map +1 -1
- package/dist/constants/build-presets.js +51 -34
- package/dist/constants/build-presets.js.map +1 -1
- package/dist/constants/build.js +11 -4
- package/dist/constants/build.js.map +1 -1
- package/dist/constants/colors.js +9 -3
- package/dist/constants/colors.js.map +1 -1
- package/dist/constants/dts.js +10 -3
- package/dist/constants/dts.js.map +1 -1
- package/dist/constants/file.js +9 -3
- package/dist/constants/file.js.map +1 -1
- package/dist/constants/legacy-build-presets.js +31 -22
- package/dist/constants/legacy-build-presets.js.map +1 -1
- package/dist/constants/log.js +10 -3
- package/dist/constants/log.js.map +1 -1
- package/dist/dev.d.ts +1 -1
- package/dist/dev.js +26 -35
- package/dist/dev.js.map +1 -1
- package/dist/error.js +12 -3
- package/dist/error.js.map +1 -1
- package/dist/hooks/build.d.ts +5 -8
- package/dist/hooks/build.js +8 -4
- package/dist/hooks/build.js.map +1 -1
- package/dist/hooks/dev.d.ts +1 -1
- package/dist/hooks/dev.js +8 -4
- package/dist/hooks/dev.js.map +1 -1
- package/dist/hooks/index.d.ts +6 -9
- package/dist/hooks/index.js +21 -19
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/misc.js +7 -3
- package/dist/hooks/misc.js.map +1 -1
- package/dist/index.js +9 -4
- package/dist/index.js.map +1 -1
- package/dist/locale/en.d.ts +1 -0
- package/dist/locale/en.js +11 -4
- package/dist/locale/en.js.map +1 -1
- package/dist/locale/index.d.ts +2 -0
- package/dist/locale/index.js +8 -3
- package/dist/locale/index.js.map +1 -1
- package/dist/locale/zh.d.ts +1 -0
- package/dist/locale/zh.js +11 -4
- package/dist/locale/zh.js.map +1 -1
- package/dist/plugins.js +7 -3
- package/dist/plugins.js.map +1 -1
- package/dist/types/color.js +17 -0
- package/dist/types/color.js.map +1 -0
- package/dist/types/command.d.ts +2 -1
- package/dist/types/command.js +17 -0
- package/dist/types/command.js.map +1 -0
- package/dist/types/config/index.d.ts +3 -6
- package/dist/types/config/index.js +3 -3
- package/dist/types/config/index.js.map +1 -1
- package/dist/types/config/style.js +17 -0
- package/dist/types/config/style.js.map +1 -0
- package/dist/types/context.js +17 -0
- package/dist/types/context.js.map +1 -0
- package/dist/types/copy.js +17 -0
- package/dist/types/copy.js.map +1 -0
- package/dist/types/dts.js +17 -0
- package/dist/types/dts.js.map +1 -0
- package/dist/types/hooks.d.ts +2 -2
- package/dist/types/hooks.js +17 -0
- package/dist/types/hooks.js.map +1 -0
- package/dist/types/index.js +7 -7
- package/dist/types/index.js.map +1 -1
- package/dist/types/utils.js +17 -0
- package/dist/types/utils.js.map +1 -0
- package/dist/utils/builder.js +13 -26
- package/dist/utils/builder.js.map +1 -1
- package/dist/utils/config.js +33 -38
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/context.js +14 -22
- package/dist/utils/context.js.map +1 -1
- package/dist/utils/dts.js +39 -50
- package/dist/utils/dts.js.map +1 -1
- package/dist/utils/input.js +19 -30
- package/dist/utils/input.js.map +1 -1
- package/dist/utils/language.js +17 -24
- package/dist/utils/language.js.map +1 -1
- package/dist/utils/libuild-plugins.js +16 -23
- package/dist/utils/libuild-plugins.js.map +1 -1
- package/dist/utils/log.js +15 -23
- package/dist/utils/log.js.map +1 -1
- package/dist/utils/onExit.js +14 -22
- package/dist/utils/onExit.js.map +1 -1
- package/dist/utils/path.js +11 -25
- package/dist/utils/path.js.map +1 -1
- package/dist/utils/style.js +20 -25
- package/dist/utils/style.js.map +1 -1
- package/dist/utils/tspaths-transform.js +7 -3
- package/dist/utils/tspaths-transform.js.map +1 -1
- package/package.json +13 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,157 @@
|
|
|
1
1
|
# @modern-js/module-tools
|
|
2
2
|
|
|
3
|
+
## 2.0.0-beta.7
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- dda38c9c3e: chore: v2
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- d4a456659b: chore: rename plugin-jarvis to plugin-lint
|
|
12
|
+
|
|
13
|
+
chore: 重命名 plugin-jarvis 为 plugin-lint
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [c9e800d39a]
|
|
16
|
+
- Updated dependencies [edd1cfb1af]
|
|
17
|
+
- Updated dependencies [d4a456659b]
|
|
18
|
+
- Updated dependencies [f680410886]
|
|
19
|
+
- Updated dependencies [dda38c9c3e]
|
|
20
|
+
- Updated dependencies [8b8e1bb571]
|
|
21
|
+
- Updated dependencies [bbe4c4ab64]
|
|
22
|
+
- @modern-js/core@2.0.0-beta.7
|
|
23
|
+
- @modern-js/utils@2.0.0-beta.7
|
|
24
|
+
- @modern-js/plugin-lint@2.0.0-beta.7
|
|
25
|
+
- @modern-js/plugin-changeset@2.0.0-beta.7
|
|
26
|
+
- @modern-js/plugin-i18n@2.0.0-beta.7
|
|
27
|
+
- @modern-js/new-action@2.0.0-beta.7
|
|
28
|
+
- @modern-js/plugin@2.0.0-beta.7
|
|
29
|
+
- @modern-js/upgrade@2.0.0-beta.7
|
|
30
|
+
|
|
31
|
+
## 2.0.0-beta.6
|
|
32
|
+
|
|
33
|
+
### Major Changes
|
|
34
|
+
|
|
35
|
+
- dda38c9c3e: chore: v2
|
|
36
|
+
|
|
37
|
+
### Minor Changes
|
|
38
|
+
|
|
39
|
+
- 92f0eade39: feat:
|
|
40
|
+
|
|
41
|
+
1. add style config and add new hook
|
|
42
|
+
2. add dts alias logic
|
|
43
|
+
3. add copy logic
|
|
44
|
+
4. add log logic
|
|
45
|
+
5. add skipDeps config
|
|
46
|
+
|
|
47
|
+
feat:
|
|
48
|
+
|
|
49
|
+
1. 添加样式配置以及新的 hook
|
|
50
|
+
2. 添加 dts 别名处理
|
|
51
|
+
3. 添加 copy 逻辑
|
|
52
|
+
4. 添加日志逻辑
|
|
53
|
+
5. 添加 skipDeps 配置
|
|
54
|
+
|
|
55
|
+
- 4fd53b48fd: feat: add normalize config logic
|
|
56
|
+
feat: 添加处理配置的逻辑
|
|
57
|
+
- f0ee9120db: feat: change dev menu log
|
|
58
|
+
feat: 修改 dev 菜单展示的内容
|
|
59
|
+
- 148fbf8e25: feat: update afterBuild options
|
|
60
|
+
feat: 更新 afterBuild 函数的参数
|
|
61
|
+
- 0bb776858a: feat: add ModuleContext
|
|
62
|
+
feat: 添加 ModuleContext
|
|
63
|
+
- e6bfca6d31: feat: add type define and schema for config
|
|
64
|
+
feat: 为配置增加类型定义和 schema
|
|
65
|
+
- 54abc88a2a: feat: add new and upgrade command
|
|
66
|
+
feat: 添加 new 和 upgrade 命令
|
|
67
|
+
- e4558a0bc4: feat:
|
|
68
|
+
|
|
69
|
+
1. add `runBin` function
|
|
70
|
+
2. config internal plugins constants in the app/module/doc tools
|
|
71
|
+
3. add app/module/doc tools internal plugins
|
|
72
|
+
|
|
73
|
+
feat:
|
|
74
|
+
|
|
75
|
+
1. 添加 `runBin` 函数
|
|
76
|
+
2. 在 app/module/doc tools 里配置内部插件
|
|
77
|
+
3. 增加 app/module/doc tools 使用的插件常量
|
|
78
|
+
|
|
79
|
+
### Patch Changes
|
|
80
|
+
|
|
81
|
+
- d6546ad916: add buildConfig style in module-tools and remove tools
|
|
82
|
+
在 module-tools 里新增 buildConfig style 并删除 tools
|
|
83
|
+
- d61ca88a0b: update speedy version
|
|
84
|
+
更新依赖里 speedy 的版本
|
|
85
|
+
- 94339fc: support svgr
|
|
86
|
+
支持将 svg 转化为 react 组件
|
|
87
|
+
- 9f9ef4e6e3: fix: fix alias resolve
|
|
88
|
+
fix: 修复别名处理
|
|
89
|
+
- b8bbe036c7: feat: export Hooks type
|
|
90
|
+
feat: 导出 Hooks 类型
|
|
91
|
+
- 5282947: fix the wrong error message
|
|
92
|
+
修复错误的报错信息
|
|
93
|
+
- cc971eabfc: refactor: move server plugin load logic in `@modern-js/core`
|
|
94
|
+
refactor:移除在 `@modern-js/core` 中的 server 插件加载逻辑
|
|
95
|
+
- f037ac0: upgrade libuild version and remove warning log
|
|
96
|
+
升级 libuild 版本并移除构建的警告信息
|
|
97
|
+
- ebbeed1ece: update speedy-core to fix sass resolve error
|
|
98
|
+
更新 speedy-core 版本以修复 sass resolve 错误
|
|
99
|
+
- d4a456659b: chore: rename plugin-jarvis to plugin-lint
|
|
100
|
+
|
|
101
|
+
chore: 重命名 plugin-jarvis 为 plugin-lint
|
|
102
|
+
|
|
103
|
+
- b1bc873: fix dts bundle compilation options
|
|
104
|
+
修复打包类型描述文件的 compilation options
|
|
105
|
+
- 540de1fd5d: fix: filename typo, color.ts --> colors.ts
|
|
106
|
+
fix: 文件名错误,color.ts 修改为 colors.ts
|
|
107
|
+
- a2c8cc3eb5: fix: change tools define userconfig type
|
|
108
|
+
fix: 修改工程定义的 UserConfig 类型
|
|
109
|
+
- 1be4ba1ccd: feat: add platform build log
|
|
110
|
+
feat: 添加 platform 构建的 log 内容
|
|
111
|
+
- 14b712da84: fix: use consistent alias type and default value across packages
|
|
112
|
+
|
|
113
|
+
fix: 在各个包中使用一致的 alias 类型定义和默认值
|
|
114
|
+
|
|
115
|
+
- Updated dependencies [7879e8f711]
|
|
116
|
+
- Updated dependencies [c9e800d39a]
|
|
117
|
+
- Updated dependencies [6aca875011]
|
|
118
|
+
- Updated dependencies [85edee888c]
|
|
119
|
+
- Updated dependencies [2e6031955e]
|
|
120
|
+
- Updated dependencies [7b7d12cf8f]
|
|
121
|
+
- Updated dependencies [7efeed4]
|
|
122
|
+
- Updated dependencies [92f0eade39]
|
|
123
|
+
- Updated dependencies [edd1cfb1af]
|
|
124
|
+
- Updated dependencies [cc971eabfc]
|
|
125
|
+
- Updated dependencies [5b9049f2e9]
|
|
126
|
+
- Updated dependencies [a3af050486]
|
|
127
|
+
- Updated dependencies [d4a456659b]
|
|
128
|
+
- Updated dependencies [92004d1906]
|
|
129
|
+
- Updated dependencies [b8bbe036c7]
|
|
130
|
+
- Updated dependencies [f680410886]
|
|
131
|
+
- Updated dependencies [d5a31df781]
|
|
132
|
+
- Updated dependencies [dda38c9c3e]
|
|
133
|
+
- Updated dependencies [8b8e1bb571]
|
|
134
|
+
- Updated dependencies [3bbea92b2a]
|
|
135
|
+
- Updated dependencies [b710adb843]
|
|
136
|
+
- Updated dependencies [b7a96c35fc]
|
|
137
|
+
- Updated dependencies [cce8ecee2d]
|
|
138
|
+
- Updated dependencies [f179749375]
|
|
139
|
+
- Updated dependencies [b8494ef33b]
|
|
140
|
+
- Updated dependencies [ea7cf06257]
|
|
141
|
+
- Updated dependencies [bbe4c4ab64]
|
|
142
|
+
- Updated dependencies [e4558a0bc4]
|
|
143
|
+
- Updated dependencies [abf3421a75]
|
|
144
|
+
- Updated dependencies [543be9558e]
|
|
145
|
+
- Updated dependencies [14b712da84]
|
|
146
|
+
- @modern-js/utils@2.0.0-beta.6
|
|
147
|
+
- @modern-js/core@2.0.0-beta.6
|
|
148
|
+
- @modern-js/plugin-lint@2.0.0-beta.6
|
|
149
|
+
- @modern-js/plugin@2.0.0-beta.6
|
|
150
|
+
- @modern-js/plugin-changeset@2.0.0-beta.6
|
|
151
|
+
- @modern-js/plugin-i18n@2.0.0-beta.6
|
|
152
|
+
- @modern-js/new-action@2.0.0-beta.6
|
|
153
|
+
- @modern-js/upgrade@2.0.0-beta.6
|
|
154
|
+
|
|
3
155
|
## 2.0.0-beta.4
|
|
4
156
|
|
|
5
157
|
### Major Changes
|
package/dist/build.d.ts
ADDED
package/dist/build.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var __async = (__this, __arguments, generator) => {
|
|
25
|
+
return new Promise((resolve, reject) => {
|
|
26
|
+
var fulfilled = (value) => {
|
|
27
|
+
try {
|
|
28
|
+
step(generator.next(value));
|
|
29
|
+
} catch (e) {
|
|
30
|
+
reject(e);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
var rejected = (value) => {
|
|
34
|
+
try {
|
|
35
|
+
step(generator.throw(value));
|
|
36
|
+
} catch (e) {
|
|
37
|
+
reject(e);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
41
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var build_exports = {};
|
|
45
|
+
__export(build_exports, {
|
|
46
|
+
build: () => build
|
|
47
|
+
});
|
|
48
|
+
module.exports = __toCommonJS(build_exports);
|
|
49
|
+
var import_utils = require("@modern-js/utils");
|
|
50
|
+
const debug = (0, import_utils.createDebugger)("module-tools");
|
|
51
|
+
const build = (api, options, context) => __async(void 0, null, function* () {
|
|
52
|
+
if (options.platform) {
|
|
53
|
+
const { buildPlatform } = yield Promise.resolve().then(() => __toESM(require("./builder/platform")));
|
|
54
|
+
yield buildPlatform(options, api, context);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const runner = api.useHookRunners();
|
|
58
|
+
const { normalizeBuildConfig } = yield Promise.resolve().then(() => __toESM(require("./config/normalize")));
|
|
59
|
+
const resolvedBuildConfig = yield normalizeBuildConfig(api, context, options);
|
|
60
|
+
debug("resolvedBuildConfig", resolvedBuildConfig);
|
|
61
|
+
yield runner.beforeBuild({
|
|
62
|
+
config: resolvedBuildConfig,
|
|
63
|
+
cliOptions: options
|
|
64
|
+
});
|
|
65
|
+
const builder = yield Promise.resolve().then(() => __toESM(require("./builder")));
|
|
66
|
+
yield builder.run({ cmdOptions: options, resolvedBuildConfig, context }, api);
|
|
67
|
+
});
|
|
68
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
69
|
+
0 && (module.exports = {
|
|
70
|
+
build
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
//# sourceMappingURL=build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAA+B;AAG/B,MAAM,YAAQ,6BAAe,cAAc;AAEpC,MAAM,QAAQ,CACnB,KACA,SACA,YACG;AACH,MAAI,QAAQ,UAAU;AACpB,UAAM,EAAE,cAAc,IAAI,MAAM,6CAAO;AACvC,UAAM,cAAc,SAAS,KAAK,OAAO;AACzC;AAAA,EACF;AAEA,QAAM,SAAS,IAAI,eAAe;AAElC,QAAM,EAAE,qBAAqB,IAAI,MAAM,6CAAO;AAC9C,QAAM,sBAAsB,MAAM,qBAAqB,KAAK,SAAS,OAAO;AAE5E,QAAM,uBAAuB,mBAAmB;AAEhD,QAAM,OAAO,YAAY;AAAA,IACvB,QAAQ;AAAA,IACR,YAAY;AAAA,EACd,CAAC;AACD,QAAM,UAAU,MAAM,6CAAO;AAC7B,QAAM,QAAQ,IAAI,EAAE,YAAY,SAAS,qBAAqB,QAAQ,GAAG,GAAG;AAC9E;;;;;","names":[],"sources":["../src/build.ts"],"sourcesContent":["import type { PluginAPI } from '@modern-js/core';\nimport { createDebugger } from '@modern-js/utils';\nimport type { ModuleTools, ModuleContext, BuildCommandOptions } from './types';\n\nconst debug = createDebugger('module-tools');\n\nexport const build = async (\n api: PluginAPI<ModuleTools>,\n options: BuildCommandOptions,\n context: ModuleContext,\n) => {\n if (options.platform) {\n const { buildPlatform } = await import('./builder/platform');\n await buildPlatform(options, api, context);\n return;\n }\n\n const runner = api.useHookRunners();\n\n const { normalizeBuildConfig } = await import('./config/normalize');\n const resolvedBuildConfig = await normalizeBuildConfig(api, context, options);\n\n debug('resolvedBuildConfig', resolvedBuildConfig);\n\n await runner.beforeBuild({\n config: resolvedBuildConfig,\n cliOptions: options,\n });\n const builder = await import('./builder');\n await builder.run({ cmdOptions: options, resolvedBuildConfig, context }, api);\n};\n"]}
|
package/dist/builder/build.js
CHANGED
|
@@ -1,43 +1,17 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var stdin_exports = {};
|
|
19
|
-
__export(stdin_exports, {
|
|
20
|
-
buildInJsProject: () => buildInJsProject,
|
|
21
|
-
buildInTsProject: () => buildInTsProject,
|
|
22
|
-
buildLib: () => buildLib,
|
|
23
|
-
generatorDts: () => generatorDts,
|
|
24
|
-
runBuildTask: () => runBuildTask
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(stdin_exports);
|
|
27
1
|
var __create = Object.create;
|
|
28
|
-
var
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
29
3
|
var __defProps = Object.defineProperties;
|
|
30
|
-
var
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
31
5
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
32
|
-
var
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
33
7
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
34
8
|
var __getProtoOf = Object.getPrototypeOf;
|
|
35
|
-
var
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
36
10
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
37
|
-
var __defNormalProp = (obj, key, value) => key in obj ?
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
38
12
|
var __spreadValues = (a, b) => {
|
|
39
13
|
for (var prop in b || (b = {}))
|
|
40
|
-
if (
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
41
15
|
__defNormalProp(a, prop, b[prop]);
|
|
42
16
|
if (__getOwnPropSymbols)
|
|
43
17
|
for (var prop of __getOwnPropSymbols(b)) {
|
|
@@ -47,18 +21,23 @@ var __spreadValues = (a, b) => {
|
|
|
47
21
|
return a;
|
|
48
22
|
};
|
|
49
23
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
50
|
-
var
|
|
24
|
+
var __export = (target, all) => {
|
|
25
|
+
for (var name in all)
|
|
26
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
27
|
+
};
|
|
28
|
+
var __copyProps = (to, from, except, desc) => {
|
|
51
29
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
52
|
-
for (let key of
|
|
53
|
-
if (!
|
|
54
|
-
|
|
30
|
+
for (let key of __getOwnPropNames(from))
|
|
31
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
32
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
55
33
|
}
|
|
56
34
|
return to;
|
|
57
35
|
};
|
|
58
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {},
|
|
59
|
-
isNodeMode || !mod || !mod.__esModule ?
|
|
36
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
37
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
60
38
|
mod
|
|
61
39
|
));
|
|
40
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
62
41
|
var __async = (__this, __arguments, generator) => {
|
|
63
42
|
return new Promise((resolve, reject) => {
|
|
64
43
|
var fulfilled = (value) => {
|
|
@@ -79,6 +58,16 @@ var __async = (__this, __arguments, generator) => {
|
|
|
79
58
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
80
59
|
});
|
|
81
60
|
};
|
|
61
|
+
var build_exports = {};
|
|
62
|
+
__export(build_exports, {
|
|
63
|
+
buildInJsProject: () => buildInJsProject,
|
|
64
|
+
buildInTsProject: () => buildInTsProject,
|
|
65
|
+
buildLib: () => buildLib,
|
|
66
|
+
generatorDts: () => generatorDts,
|
|
67
|
+
runBuildTask: () => runBuildTask
|
|
68
|
+
});
|
|
69
|
+
module.exports = __toCommonJS(build_exports);
|
|
70
|
+
var import_path = require("path");
|
|
82
71
|
const runBuildTask = (options, api) => __async(void 0, null, function* () {
|
|
83
72
|
const { buildConfig, context } = options;
|
|
84
73
|
const { appDirectory, isTsProject } = context;
|
|
@@ -151,7 +140,7 @@ const buildLib = (config, api, options) => __async(void 0, null, function* () {
|
|
|
151
140
|
buildType,
|
|
152
141
|
sourceMap,
|
|
153
142
|
format,
|
|
154
|
-
|
|
143
|
+
outDir: distPath,
|
|
155
144
|
asset,
|
|
156
145
|
jsx,
|
|
157
146
|
input,
|
|
@@ -170,17 +159,20 @@ const buildLib = (config, api, options) => __async(void 0, null, function* () {
|
|
|
170
159
|
} = config;
|
|
171
160
|
const { appDirectory } = api.useAppContext();
|
|
172
161
|
const { slash } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
162
|
+
const root = slash(appDirectory);
|
|
163
|
+
const outdir = slash(distPath);
|
|
164
|
+
const assetOutDir = asset.path ? slash(asset.path) : asset.path;
|
|
165
|
+
const { less, sass, postcss, inject, modules, autoModules } = style;
|
|
173
166
|
const { es5Plugin, umdPlugin, transformPlugin } = yield Promise.resolve().then(() => __toESM(require("@modern-js/libuild-plugin-swc")));
|
|
174
167
|
const plugins = target === "es5" ? [es5Plugin()] : [];
|
|
175
168
|
if (format === "umd") {
|
|
176
169
|
plugins.push(umdPlugin(umdModuleName));
|
|
177
170
|
}
|
|
178
|
-
const {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
((_a = userTsconfig.compilerOptions) == null ? void 0 : _a.emitDecoratorMetadata) && plugins.push(
|
|
171
|
+
const { getProjectTsconfig } = yield Promise.resolve().then(() => __toESM(require("./dts/tsc")));
|
|
172
|
+
const tsconfigPath = dts ? dts.tsconfigPath : (0, import_path.join)(appDirectory, "./tsconfig.json");
|
|
173
|
+
const userTsconfig = yield getProjectTsconfig(tsconfigPath);
|
|
174
|
+
if ((_a = userTsconfig == null ? void 0 : userTsconfig.compilerOptions) == null ? void 0 : _a.emitDecoratorMetadata) {
|
|
175
|
+
plugins.push(
|
|
184
176
|
transformPlugin({
|
|
185
177
|
jsc: {
|
|
186
178
|
transform: {
|
|
@@ -191,10 +183,14 @@ const buildLib = (config, api, options) => __async(void 0, null, function* () {
|
|
|
191
183
|
})
|
|
192
184
|
);
|
|
193
185
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
186
|
+
if (asset.svgr) {
|
|
187
|
+
const { svgrPlugin } = yield Promise.resolve().then(() => __toESM(require("@modern-js/libuild-plugin-svgr")));
|
|
188
|
+
const options2 = typeof asset.svgr === "boolean" ? {} : asset.svgr;
|
|
189
|
+
plugins.push(svgrPlugin(options2));
|
|
190
|
+
}
|
|
191
|
+
const { watchPlugin, externalPlugin } = yield Promise.resolve().then(() => __toESM(require("../utils/libuild-plugins")));
|
|
192
|
+
plugins.push(watchPlugin(config));
|
|
193
|
+
plugins.push(externalPlugin(config, { appDirectory }));
|
|
198
194
|
const buildConfig = {
|
|
199
195
|
root,
|
|
200
196
|
watch,
|
|
@@ -229,13 +225,13 @@ const buildLib = (config, api, options) => __async(void 0, null, function* () {
|
|
|
229
225
|
autoExternal,
|
|
230
226
|
bundle: buildType === "bundle",
|
|
231
227
|
outbase: sourceDir,
|
|
228
|
+
logLevel: "error",
|
|
232
229
|
esbuildOptions: (options2) => __spreadProps(__spreadValues({}, options2), {
|
|
233
230
|
supported: {
|
|
234
231
|
"dynamic-import": !(["cjs", "umd"].includes(format) && buildType === "bundleless")
|
|
235
232
|
}
|
|
236
233
|
})
|
|
237
234
|
};
|
|
238
|
-
plugins.push(externalPlugin(config, { appDirectory }));
|
|
239
235
|
try {
|
|
240
236
|
const { Libuilder } = yield Promise.resolve().then(() => __toESM(require("@modern-js/libuild")));
|
|
241
237
|
const runner = api.useHookRunners();
|
|
@@ -257,9 +253,17 @@ const buildLib = (config, api, options) => __async(void 0, null, function* () {
|
|
|
257
253
|
throw new InternalBuildError(e, {
|
|
258
254
|
target,
|
|
259
255
|
format,
|
|
260
|
-
buildType
|
|
256
|
+
buildType
|
|
261
257
|
});
|
|
262
258
|
}
|
|
263
259
|
});
|
|
260
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
261
|
+
0 && (module.exports = {
|
|
262
|
+
buildInJsProject,
|
|
263
|
+
buildInTsProject,
|
|
264
|
+
buildLib,
|
|
265
|
+
generatorDts,
|
|
266
|
+
runBuildTask
|
|
267
|
+
});
|
|
264
268
|
|
|
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kB,EAChB,CAAC,OAAO,KAAK,EAAE,SAAS,MAAM,KAAK,cAAc;AAAA,MAErD;AAAA,IACF;AAAA,EACF;AACA,UAAQ,KAAK,eAAe,QAAQ,EAAE,aAAa,CAAC,CAAC;AAErD,MAAI;AACF,UAAM,EAAE,UAAU,IAAI,MAAM,6CAAO;AAEnC,UAAM,SAAS,IAAI,eAAe;AAClC,UAAM,sBAAsB,MAAM,OAAO,cAAc,aAAa;AAAA,MAClE,QAAQ,OAAK;AAAA,IACf,CAAC;AAED,UAAM,UAAU,MAAM,UAAU,OAAO,mBAAmB;AAC1D,UAAM,QAAQ,MAAM;AAEpB,QAAI,OAAO;AACT,YAAM,EAAE,kBAAkB,IAAI,MAAM,6CAAO;AAC3C,YAAM,EAAE,mBAAmB,IAAI,MAAM,6CAAO;AAC5C,YAAM,YAAY,IAChB,cAAc,WAAW,WAAW,iBACjC,UAAU;AAEf,cAAQ;AAAA,QACN,MAAM,kBAAkB,WAAW,mBAAmB,OAAO;AAAA,MAC/D;AAAA,IACF;AAAA,EACF,SAAS,GAAT;AACE,UAAM,EAAE,mBAAmB,IAAI,MAAM,6CAAO;AAC5C,UAAM,IAAI,mBAAmB,GAAG;AAAA,MAC9B;AAAA,MACA;AAAA,MACA,WAAW;AAAA,IACb,CAAC;AAAA,EACH;AACF;","names":["options"],"sources":["../../src/builder/build.ts"],"sourcesContent":["import type { CLIConfig } from '@modern-js/libuild';\nimport type {\n BuildCommandOptions,\n BaseBuildConfig,\n ModuleTools,\n PluginAPI,\n DTSOptions,\n ModuleContext,\n} from '../types';\n\nexport const runBuildTask = async (\n options: {\n buildConfig: BaseBuildConfig;\n buildCmdOptions: BuildCommandOptions;\n context: ModuleContext;\n },\n api: PluginAPI<ModuleTools>,\n) => {\n const { buildConfig, context } = options;\n const { appDirectory, isTsProject } = context;\n\n if (isTsProject) {\n await buildInTsProject(options, api);\n } else {\n await buildInJsProject(options, api);\n }\n\n const { copyTask } = await import('./copy');\n await copyTask(buildConfig, { appDirectory });\n};\n\nexport const buildInTsProject = async (\n options: {\n buildConfig: BaseBuildConfig;\n buildCmdOptions: BuildCommandOptions;\n context: ModuleContext;\n },\n api: PluginAPI<ModuleTools>,\n) => {\n const { buildConfig, buildCmdOptions } = options;\n const dts = buildCmdOptions.dts ? buildConfig.dts : false;\n const skipBuildLib = buildConfig.dts ? buildConfig.dts.only : false;\n const watch = buildCmdOptions.watch ?? false;\n\n if (dts === false) {\n // --no-dts and buildConfig is `{ dts: { only: true } }`, then skip.\n !skipBuildLib && (await buildLib(buildConfig, api, { watch }));\n } else {\n const tasks = dts.only ? [generatorDts] : [buildLib, generatorDts];\n const { default: pMap } = await import('../../compiled/p-map');\n await pMap(tasks, async task => {\n await task(buildConfig, api as any, { watch, dts });\n });\n }\n};\n\nexport const buildInJsProject = async (\n options: {\n buildConfig: BaseBuildConfig;\n buildCmdOptions: BuildCommandOptions;\n context: ModuleContext;\n },\n api: PluginAPI<ModuleTools>,\n) => {\n const { buildConfig, buildCmdOptions } = options;\n const dts = buildCmdOptions.dts ? buildConfig.dts : false;\n const watch = buildCmdOptions.watch ?? false;\n\n if (dts !== false && dts.only) {\n return;\n }\n\n await buildLib(buildConfig, api, { watch });\n};\n\nexport const generatorDts = async (\n config: BaseBuildConfig,\n api: PluginAPI,\n options: {\n watch: boolean;\n dts: DTSOptions;\n },\n) => {\n const { runRollup, runTsc } = await import('./dts');\n const { watch, dts } = options;\n const { buildType, input, sourceDir, alias } = config;\n const { appDirectory } = api.useAppContext();\n const { tsconfigPath, distPath } = dts;\n if (buildType === 'bundle') {\n const { getFinalExternals } = await import('../utils/builder');\n const finalExternals = await getFinalExternals(config, { appDirectory });\n\n await runRollup({\n distDir: distPath,\n watch,\n externals: finalExternals,\n input,\n tsconfigPath,\n });\n } else {\n await runTsc({\n appDirectory,\n alias,\n distAbsPath: distPath,\n watch,\n tsconfigPath,\n sourceDir,\n });\n }\n};\n\nexport const buildLib = async (\n config: BaseBuildConfig,\n api: PluginAPI<ModuleTools>,\n options: {\n watch: boolean;\n },\n) => {\n const { watch } = options;\n const {\n target,\n buildType,\n sourceMap,\n format,\n outdir: distPath,\n asset,\n jsx,\n input,\n platform,\n splitting,\n minify,\n sourceDir,\n umdGlobals,\n umdModuleName,\n define,\n alias,\n style,\n externals,\n autoExternal,\n dts,\n } = config;\n const { appDirectory } = api.useAppContext();\n const { slash } = await import('@modern-js/utils');\n const { es5Plugin, umdPlugin, transformPlugin } = await import(\n '@modern-js/libuild-plugin-swc'\n );\n const plugins = target === 'es5' ? [es5Plugin()] : [];\n if (format === 'umd') {\n plugins.push(umdPlugin(umdModuleName));\n }\n const { watchPlugin, externalPlugin } = await import(\n '../utils/libuild-plugins'\n );\n plugins.push(watchPlugin(config));\n if (dts) {\n const { getProjectTsconfig } = await import('./dts/tsc');\n const userTsconfig = await getProjectTsconfig(dts.tsconfigPath);\n userTsconfig.compilerOptions?.emitDecoratorMetadata &&\n plugins.push(\n transformPlugin({\n jsc: {\n transform: {\n legacyDecorator: true,\n decoratorMetadata: true,\n },\n },\n }),\n );\n }\n const root = slash(appDirectory);\n const outdir = slash(distPath);\n const assetOutDir = asset.path ? slash(asset.path) : asset.path;\n const { less, sass, postcss, inject, modules, autoModules } = style;\n const buildConfig: CLIConfig = {\n root,\n watch,\n target,\n sourceMap,\n format,\n outdir,\n define,\n style: {\n less,\n sass,\n postcss,\n inject,\n modules,\n autoModules,\n },\n resolve: {\n alias,\n },\n asset: {\n ...asset,\n outdir: assetOutDir,\n },\n plugins,\n jsx,\n input,\n platform,\n splitting,\n minify,\n sourceDir,\n globals: umdGlobals,\n external: externals,\n autoExternal,\n bundle: buildType === 'bundle',\n // outbase for [dir]/[name]\n outbase: sourceDir,\n esbuildOptions: (options: any) => ({\n ...options,\n supported: {\n 'dynamic-import': !(\n ['cjs', 'umd'].includes(format) && buildType === 'bundleless'\n ),\n },\n }),\n };\n plugins.push(externalPlugin(config, { appDirectory }));\n\n try {\n const { Libuilder } = await import('@modern-js/libuild');\n\n const runner = api.useHookRunners();\n const modifiedBuildConfig = await runner.modifyLibuild(buildConfig, {\n onLast: c => c,\n });\n\n const builder = await Libuilder.create(modifiedBuildConfig);\n await builder.build();\n\n if (watch) {\n const { watchSectionTitle } = await import('../utils/log');\n const { SectionTitleStatus } = await import('../constants/log');\n const titleText = `[${\n buildType === 'bundle' ? 'Bundle' : 'Bundleless'\n }: ${format}_${target}]`;\n\n console.info(\n await watchSectionTitle(titleText, SectionTitleStatus.Success),\n );\n }\n } catch (e: any) {\n const { InternalBuildError } = await import('../error');\n throw new InternalBuildError(e, {\n target,\n format,\n buildType: 'bundle',\n });\n }\n};\n"]}
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAqB;AAWd,MAAM,eAAe,CAC1B,SAKA,QACG;AACH,QAAM,EAAE,aAAa,QAAQ,IAAI;AACjC,QAAM,EAAE,cAAc,YAAY,IAAI;AAEtC,MAAI,aAAa;AACf,UAAM,iBAAiB,SAAS,GAAG;AAAA,EACrC,OAAO;AACL,UAAM,iBAAiB,SAAS,GAAG;AAAA,EACrC;AAEA,QAAM,EAAE,SAAS,IAAI,MAAM,6CAAO;AAClC,QAAM,SAAS,aAAa,EAAE,aAAa,CAAC;AAC9C;AAEO,MAAM,mBAAmB,CAC9B,SAKA,QACG;AAvCL;AAwCE,QAAM,EAAE,aAAa,gBAAgB,IAAI;AACzC,QAAM,MAAM,gBAAgB,MAAM,YAAY,MAAM;AACpD,QAAM,eAAe,YAAY,MAAM,YAAY,IAAI,OAAO;AAC9D,QAAM,SAAQ,qBAAgB,UAAhB,YAAyB;AAEvC,MAAI,QAAQ,OAAO;AAEjB,KAAC,iBAAiB,MAAM,SAAS,aAAa,KAAK,EAAE,MAAM,CAAC;AAAA,EAC9D,OAAO;AACL,UAAM,QAAQ,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BAAkB,WAAW,mBAAmB,OAAO;AAAA,MAC/D;AAAA,IACF;AAAA,EACF,SAAS,GAAP;AACA,UAAM,EAAE,mBAAmB,IAAI,MAAM,6CAAO;AAC5C,UAAM,IAAI,mBAAmB,GAAG;AAAA,MAC9B;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AACF;;;;;;;;;","names":["options"],"sources":["../../src/builder/build.ts"],"sourcesContent":["import { join } from 'path';\nimport type { CLIConfig } from '@modern-js/libuild';\nimport type {\n BuildCommandOptions,\n BaseBuildConfig,\n ModuleTools,\n PluginAPI,\n DTSOptions,\n ModuleContext,\n} from '../types';\n\nexport const runBuildTask = async (\n options: {\n buildConfig: BaseBuildConfig;\n buildCmdOptions: BuildCommandOptions;\n context: ModuleContext;\n },\n api: PluginAPI<ModuleTools>,\n) => {\n const { buildConfig, context } = options;\n const { appDirectory, isTsProject } = context;\n\n if (isTsProject) {\n await buildInTsProject(options, api);\n } else {\n await buildInJsProject(options, api);\n }\n\n const { copyTask } = await import('./copy');\n await copyTask(buildConfig, { appDirectory });\n};\n\nexport const buildInTsProject = async (\n options: {\n buildConfig: BaseBuildConfig;\n buildCmdOptions: BuildCommandOptions;\n context: ModuleContext;\n },\n api: PluginAPI<ModuleTools>,\n) => {\n const { buildConfig, buildCmdOptions } = options;\n const dts = buildCmdOptions.dts ? buildConfig.dts : false;\n const skipBuildLib = buildConfig.dts ? buildConfig.dts.only : false;\n const watch = buildCmdOptions.watch ?? false;\n\n if (dts === false) {\n // --no-dts and buildConfig is `{ dts: { only: true } }`, then skip.\n !skipBuildLib && (await buildLib(buildConfig, api, { watch }));\n } else {\n const tasks = dts.only ? [generatorDts] : [buildLib, generatorDts];\n const { default: pMap } = await import('../../compiled/p-map');\n await pMap(tasks, async task => {\n await task(buildConfig, api as any, { watch, dts });\n });\n }\n};\n\nexport const buildInJsProject = async (\n options: {\n buildConfig: BaseBuildConfig;\n buildCmdOptions: BuildCommandOptions;\n context: ModuleContext;\n },\n api: PluginAPI<ModuleTools>,\n) => {\n const { buildConfig, buildCmdOptions } = options;\n const dts = buildCmdOptions.dts ? buildConfig.dts : false;\n const watch = buildCmdOptions.watch ?? false;\n\n if (dts !== false && dts.only) {\n return;\n }\n\n await buildLib(buildConfig, api, { watch });\n};\n\nexport const generatorDts = async (\n config: BaseBuildConfig,\n api: PluginAPI,\n options: {\n watch: boolean;\n dts: DTSOptions;\n },\n) => {\n const { runRollup, runTsc } = await import('./dts');\n const { watch, dts } = options;\n const { buildType, input, sourceDir, alias } = config;\n const { appDirectory } = api.useAppContext();\n const { tsconfigPath, distPath } = dts;\n if (buildType === 'bundle') {\n const { getFinalExternals } = await import('../utils/builder');\n const finalExternals = await getFinalExternals(config, { appDirectory });\n\n await runRollup({\n distDir: distPath,\n watch,\n externals: finalExternals,\n input,\n tsconfigPath,\n });\n } else {\n await runTsc({\n appDirectory,\n alias,\n distAbsPath: distPath,\n watch,\n tsconfigPath,\n sourceDir,\n });\n }\n};\n\nexport const buildLib = async (\n config: BaseBuildConfig,\n api: PluginAPI<ModuleTools>,\n options: {\n watch: boolean;\n },\n) => {\n const { watch } = options;\n const {\n target,\n buildType,\n sourceMap,\n format,\n outDir: distPath,\n asset,\n jsx,\n input,\n platform,\n splitting,\n minify,\n sourceDir,\n umdGlobals,\n umdModuleName,\n define,\n alias,\n style,\n externals,\n autoExternal,\n dts,\n } = config;\n const { appDirectory } = api.useAppContext();\n const { slash } = await import('@modern-js/utils');\n const root = slash(appDirectory);\n const outdir = slash(distPath);\n const assetOutDir = asset.path ? slash(asset.path) : asset.path;\n const { less, sass, postcss, inject, modules, autoModules } = style;\n\n // support es5,umd and emitDecoratorMetadata by swc\n const { es5Plugin, umdPlugin, transformPlugin } = await import(\n '@modern-js/libuild-plugin-swc'\n );\n const plugins = target === 'es5' ? [es5Plugin()] : [];\n if (format === 'umd') {\n plugins.push(umdPlugin(umdModuleName));\n }\n const { getProjectTsconfig } = await import('./dts/tsc');\n const tsconfigPath = dts\n ? dts.tsconfigPath\n : join(appDirectory, './tsconfig.json');\n const userTsconfig = await getProjectTsconfig(tsconfigPath);\n if (userTsconfig?.compilerOptions?.emitDecoratorMetadata) {\n plugins.push(\n transformPlugin({\n jsc: {\n transform: {\n legacyDecorator: true,\n decoratorMetadata: true,\n },\n },\n }),\n );\n }\n\n // support svgr\n if (asset.svgr) {\n const { svgrPlugin } = await import('@modern-js/libuild-plugin-svgr');\n const options = typeof asset.svgr === 'boolean' ? {} : asset.svgr;\n plugins.push(svgrPlugin(options));\n }\n\n // adapt module tools\n const { watchPlugin, externalPlugin } = await import(\n '../utils/libuild-plugins'\n );\n plugins.push(watchPlugin(config));\n plugins.push(externalPlugin(config, { appDirectory }));\n\n const buildConfig: CLIConfig = {\n root,\n watch,\n target,\n sourceMap,\n format,\n outdir,\n define,\n style: {\n less,\n sass,\n postcss,\n inject,\n modules,\n autoModules,\n },\n resolve: {\n alias,\n },\n asset: {\n ...asset,\n outdir: assetOutDir,\n },\n plugins,\n jsx,\n input,\n platform,\n splitting,\n minify,\n sourceDir,\n globals: umdGlobals,\n external: externals,\n autoExternal,\n bundle: buildType === 'bundle',\n // outbase for [dir]/[name]\n outbase: sourceDir,\n logLevel: 'error',\n esbuildOptions: (options: any) => ({\n ...options,\n supported: {\n 'dynamic-import': !(\n ['cjs', 'umd'].includes(format) && buildType === 'bundleless'\n ),\n },\n }),\n };\n\n try {\n const { Libuilder } = await import('@modern-js/libuild');\n\n const runner = api.useHookRunners();\n const modifiedBuildConfig = await runner.modifyLibuild(buildConfig, {\n onLast: c => c,\n });\n\n const builder = await Libuilder.create(modifiedBuildConfig);\n await builder.build();\n\n if (watch) {\n const { watchSectionTitle } = await import('../utils/log');\n const { SectionTitleStatus } = await import('../constants/log');\n const titleText = `[${\n buildType === 'bundle' ? 'Bundle' : 'Bundleless'\n }: ${format}_${target}]`;\n\n console.info(\n await watchSectionTitle(titleText, SectionTitleStatus.Success),\n );\n }\n } catch (e: any) {\n const { InternalBuildError } = await import('../error');\n throw new InternalBuildError(e, {\n target,\n format,\n buildType,\n });\n }\n};\n"]}
|
package/dist/builder/clear.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __export = (target, all) => {
|
|
6
8
|
for (var name in all)
|
|
@@ -14,31 +16,11 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
16
|
}
|
|
15
17
|
return to;
|
|
16
18
|
};
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
__export(stdin_exports, {
|
|
20
|
-
clearBuildConfigPaths: () => clearBuildConfigPaths,
|
|
21
|
-
clearDtsTemp: () => clearDtsTemp
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(stdin_exports);
|
|
24
|
-
var __create = Object.create;
|
|
25
|
-
var __defProp2 = Object.defineProperty;
|
|
26
|
-
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
27
|
-
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
28
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
29
|
-
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
30
|
-
var __copyProps2 = (to, from, except, desc) => {
|
|
31
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
32
|
-
for (let key of __getOwnPropNames2(from))
|
|
33
|
-
if (!__hasOwnProp2.call(to, key) && key !== except)
|
|
34
|
-
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
35
|
-
}
|
|
36
|
-
return to;
|
|
37
|
-
};
|
|
38
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps2(
|
|
39
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target,
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
40
21
|
mod
|
|
41
22
|
));
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
42
24
|
var __async = (__this, __arguments, generator) => {
|
|
43
25
|
return new Promise((resolve, reject) => {
|
|
44
26
|
var fulfilled = (value) => {
|
|
@@ -59,6 +41,12 @@ var __async = (__this, __arguments, generator) => {
|
|
|
59
41
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
60
42
|
});
|
|
61
43
|
};
|
|
44
|
+
var clear_exports = {};
|
|
45
|
+
__export(clear_exports, {
|
|
46
|
+
clearBuildConfigPaths: () => clearBuildConfigPaths,
|
|
47
|
+
clearDtsTemp: () => clearDtsTemp
|
|
48
|
+
});
|
|
49
|
+
module.exports = __toCommonJS(clear_exports);
|
|
62
50
|
const clearDtsTemp = () => __async(void 0, null, function* () {
|
|
63
51
|
const { fs } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
64
52
|
const { dtsTempDirectory } = yield Promise.resolve().then(() => __toESM(require("../constants/dts")));
|
|
@@ -67,8 +55,13 @@ const clearDtsTemp = () => __async(void 0, null, function* () {
|
|
|
67
55
|
const clearBuildConfigPaths = (configs) => __async(void 0, null, function* () {
|
|
68
56
|
const { fs } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
69
57
|
for (const config of configs) {
|
|
70
|
-
yield fs.remove(config.
|
|
58
|
+
yield fs.remove(config.outDir);
|
|
71
59
|
}
|
|
72
60
|
});
|
|
61
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
62
|
+
0 && (module.exports = {
|
|
63
|
+
clearBuildConfigPaths,
|
|
64
|
+
clearDtsTemp
|
|
65
|
+
});
|
|
73
66
|
|
|
74
67
|
//# sourceMappingURL=clear.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"mappings":"
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,MAAM,eAAe,MAAY;AACtC,QAAM,EAAE,GAAG,IAAI,MAAM,6CAAO;AAC5B,QAAM,EAAE,iBAAiB,IAAI,MAAM,6CAAO;AAC1C,QAAM,GAAG,OAAO,gBAAgB;AAClC;AAEO,MAAM,wBAAwB,CAAO,YAA+B;AACzE,QAAM,EAAE,GAAG,IAAI,MAAM,6CAAO;AAE5B,aAAW,UAAU,SAAS;AAC5B,UAAM,GAAG,OAAO,OAAO,MAAM;AAAA,EAC/B;AACF;;;;;;","names":[],"sources":["../../src/builder/clear.ts"],"sourcesContent":["import type { BaseBuildConfig } from '../types';\n\nexport const clearDtsTemp = async () => {\n const { fs } = await import('@modern-js/utils');\n const { dtsTempDirectory } = await import('../constants/dts');\n await fs.remove(dtsTempDirectory);\n};\n\nexport const clearBuildConfigPaths = async (configs: BaseBuildConfig[]) => {\n const { fs } = await import('@modern-js/utils');\n\n for (const config of configs) {\n await fs.remove(config.outDir);\n }\n};\n"]}
|
package/dist/builder/copy.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ import type { BaseBuildConfig } from '../types/config';
|
|
|
3
3
|
export declare const runPatterns: (pattern: CopyPattern, options: {
|
|
4
4
|
appDirectory: string;
|
|
5
5
|
enableCopySync?: boolean;
|
|
6
|
+
outDir: string;
|
|
7
|
+
defaultContext: string;
|
|
6
8
|
}) => Promise<void>;
|
|
7
9
|
export declare const copyTask: (buildConfig: BaseBuildConfig, options: {
|
|
8
10
|
appDirectory: string;
|