@modern-js/module-tools 2.10.1-beta.0 → 2.10.1-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/dist/build.js +29 -9
- package/dist/build.js.map +1 -1
- package/dist/builder/build.js +93 -52
- package/dist/builder/build.js.map +1 -1
- package/dist/builder/clear.js +29 -9
- package/dist/builder/clear.js.map +1 -1
- package/dist/builder/copy.js +82 -42
- package/dist/builder/copy.js.map +1 -1
- package/dist/builder/dts/rollup.d.ts +4 -2
- package/dist/builder/dts/rollup.js +73 -34
- package/dist/builder/dts/rollup.js.map +1 -1
- package/dist/builder/dts/tsc.js +88 -47
- package/dist/builder/dts/tsc.js.map +1 -1
- package/dist/builder/index.js +39 -18
- package/dist/builder/index.js.map +1 -1
- package/dist/builder/platform.js +46 -25
- package/dist/builder/platform.js.map +1 -1
- package/dist/cli.js +45 -23
- package/dist/cli.js.map +1 -1
- package/dist/command.js +76 -39
- package/dist/command.js.map +1 -1
- package/dist/config/defineConfig.js +18 -2
- package/dist/config/defineConfig.js.map +1 -1
- package/dist/config/normalize.js +73 -45
- package/dist/config/normalize.js.map +1 -1
- package/dist/config/schema.d.ts +12 -0
- package/dist/config/schema.js +2 -1
- package/dist/config/schema.js.map +1 -1
- package/dist/config/transformLegacyConfig.js +130 -90
- package/dist/config/transformLegacyConfig.js.map +1 -1
- package/dist/constants/build.d.ts +0 -3
- package/dist/constants/build.js +2 -11
- package/dist/constants/build.js.map +1 -1
- package/dist/constants/buildPresets.js +23 -14
- package/dist/constants/buildPresets.js.map +1 -1
- package/dist/dev.js +46 -21
- package/dist/dev.js.map +1 -1
- package/dist/error.js +2 -7
- package/dist/error.js.map +1 -1
- package/dist/hooks/index.js +15 -6
- package/dist/hooks/index.js.map +1 -1
- package/dist/locale/en.d.ts +3 -0
- package/dist/locale/en.js +5 -3
- package/dist/locale/en.js.map +1 -1
- package/dist/locale/index.d.ts +6 -0
- package/dist/locale/zh.d.ts +3 -0
- package/dist/locale/zh.js +5 -3
- package/dist/locale/zh.js.map +1 -1
- package/dist/types/config/index.d.ts +1 -0
- package/dist/types/config/index.js.map +1 -1
- package/dist/types/dts.d.ts +1 -0
- package/dist/types/dts.js.map +1 -1
- package/dist/utils/builder.js +29 -8
- package/dist/utils/builder.js.map +1 -1
- package/dist/utils/common.js +19 -3
- package/dist/utils/common.js.map +1 -1
- package/dist/utils/config.js +83 -57
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/context.js +23 -3
- package/dist/utils/context.js.map +1 -1
- package/dist/utils/dts.d.ts +6 -2
- package/dist/utils/dts.js +92 -25
- package/dist/utils/dts.js.map +1 -1
- package/dist/utils/input.js +34 -14
- package/dist/utils/input.js.map +1 -1
- package/dist/utils/language.js +23 -3
- package/dist/utils/language.js.map +1 -1
- package/dist/utils/libuildPlugins.js +30 -11
- package/dist/utils/libuildPlugins.js.map +1 -1
- package/dist/utils/log.js +26 -10
- package/dist/utils/log.js.map +1 -1
- package/dist/utils/onExit.js +26 -6
- package/dist/utils/onExit.js.map +1 -1
- package/dist/utils/path.js +23 -3
- package/dist/utils/path.js.map +1 -1
- package/dist/utils/print.js +31 -13
- package/dist/utils/print.js.map +1 -1
- package/dist/utils/style.js +52 -29
- package/dist/utils/style.js.map +1 -1
- package/lib/types.d.ts +0 -98
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"mappings":"
|
|
1
|
+
{"version":3,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMO,MAAM,UAAoB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,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f,aAAa;AAAA,EACb,eAAe;AAAA,EACf,sBAAsB;AAAA,EACtB,wBAAwB;AAAA,EACxB,eAAe;AAAA,EACf,iBAAiB;AAAA,EACjB,wBAAwB;AAAA,EACxB,0BAA0B;AAAA,EAC1B,kBAAkB;AAAA,EAClB,uBAAuB;AACzB;","names":[],"sources":["../../src/constants/buildPresets.ts"],"sourcesContent":["import type {\n PartialBuildConfig,\n PartialBaseBuildConfig,\n Target,\n} from '../types';\n\nexport const targets: Target[] = [\n 'es5',\n 'es6',\n 'es2015',\n 'es2016',\n 'es2017',\n 'es2018',\n 'es2019',\n 'es2020',\n 'es2021',\n 'es2022',\n 'esnext',\n];\n\nexport const basePresetConfig: PartialBuildConfig = {\n format: 'esm',\n target: 'es6',\n buildType: 'bundle',\n outDir: './dist',\n dts: { distPath: './types' },\n};\n\nexport const npmLibraryPresetConfig: PartialBaseBuildConfig[] = [\n {\n format: 'cjs',\n target: 'es6',\n buildType: 'bundle',\n outDir: './dist/lib',\n dts: false,\n },\n {\n format: 'esm',\n target: 'es6',\n buildType: 'bundle',\n outDir: './dist/es',\n dts: false,\n },\n {\n buildType: 'bundle',\n dts: { only: true, distPath: './types' },\n },\n];\nexport const npmLibraryWithUmdPresetConfig: PartialBaseBuildConfig[] = [\n {\n format: 'cjs',\n target: 'es6',\n buildType: 'bundle',\n outDir: './dist/lib',\n dts: false,\n },\n {\n format: 'esm',\n target: 'es6',\n buildType: 'bundle',\n outDir: './dist/es',\n dts: false,\n },\n {\n format: 'umd',\n target: 'es6',\n buildType: 'bundle',\n outDir: './dist/umd',\n dts: false,\n },\n {\n buildType: 'bundle',\n dts: { only: true, distPath: './types' },\n },\n];\nexport const npmComponentPresetConfig: PartialBaseBuildConfig[] = [\n {\n format: 'cjs',\n target: 'es6',\n buildType: 'bundleless',\n outDir: './dist/lib',\n dts: false,\n },\n {\n format: 'esm',\n target: 'es6',\n buildType: 'bundleless',\n outDir: './dist/es',\n dts: false,\n },\n {\n buildType: 'bundleless',\n outDir: './dist/types',\n dts: { only: true },\n },\n];\nexport const npmComponentWithUmdPresetConfig: PartialBaseBuildConfig[] = [\n {\n format: 'cjs',\n target: 'es6',\n buildType: 'bundleless',\n outDir: './dist/lib',\n dts: false,\n },\n {\n format: 'esm',\n target: 'es6',\n buildType: 'bundleless',\n outDir: './dist/es',\n dts: false,\n },\n {\n format: 'umd',\n target: 'es6',\n buildType: 'bundle',\n outDir: './dist/umd',\n dts: false,\n },\n {\n buildType: 'bundleless',\n dts: { only: true, distPath: './types' },\n },\n];\n\nexport const libraryPreset = { 'npm-library': npmLibraryPresetConfig };\n\nexport const libraryPresetWithTarget = targets.reduce((ret, target) => {\n ret[`npm-library-${target}`] = libraryPreset['npm-library'].map(config => {\n return { ...config, target };\n });\n return ret;\n}, {} as Record<`npm-library-${Target}`, PartialBuildConfig>);\n\nexport const libraryUmdPreset = {\n 'npm-library-with-umd': npmLibraryWithUmdPresetConfig,\n};\nexport const libraryUmdPresetWithTarget = targets.reduce((ret, target) => {\n ret[`npm-library-with-umd-${target}`] = libraryUmdPreset[\n 'npm-library-with-umd'\n ].map(config => {\n return { ...config, target };\n });\n return ret;\n}, {} as Record<`npm-library-with-umd-${Target}`, PartialBuildConfig>);\n\nexport const componentPreset = {\n 'npm-component': npmComponentPresetConfig,\n};\nexport const componentPresetWithTarget = targets.reduce((ret, target) => {\n ret[`npm-component-${target}`] = componentPreset['npm-component'].map(\n config => {\n return { ...config, target };\n },\n );\n return ret;\n}, {} as Record<`npm-component-${Target}`, PartialBuildConfig>);\n\nexport const componentUmdPreset = {\n 'npm-component-with-umd': npmComponentWithUmdPresetConfig,\n};\nexport const componentUmdPresetWithTarget = targets.reduce((ret, target) => {\n ret[`npm-component-with-umd-${target}`] = componentUmdPreset[\n 'npm-component-with-umd'\n ].map(config => {\n return { ...config, target };\n });\n return ret;\n}, {} as Record<`npm-component-with-umd-${Target}`, PartialBuildConfig>);\n\nexport const nodeBuildConfig: PartialBaseBuildConfig[] = [\n {\n buildType: 'bundleless',\n format: 'cjs',\n target: 'es2019',\n dts: false,\n outDir: './dist/cjs',\n },\n {\n buildType: 'bundleless',\n format: 'esm',\n target: 'es2019',\n dts: false,\n outDir: './dist/esm',\n },\n {\n buildType: 'bundleless',\n dts: {\n only: true,\n },\n outDir: './dist/types',\n },\n];\n\nexport const universalBuildConfig: PartialBaseBuildConfig[] = [\n {\n buildType: 'bundleless',\n format: 'cjs',\n target: 'es2019',\n dts: false,\n outDir: './dist/cjs',\n },\n {\n buildType: 'bundleless',\n format: 'esm',\n target: 'es5',\n dts: false,\n outDir: './dist/esm',\n },\n {\n buildType: 'bundleless',\n format: 'esm',\n target: 'es2019',\n dts: false,\n outDir: './dist/esm-node',\n },\n {\n buildType: 'bundleless',\n dts: {\n only: true,\n },\n outDir: './dist/types',\n },\n];\n\nexport const presetList = {\n ...libraryPreset,\n ...libraryPresetWithTarget,\n ...libraryUmdPreset,\n ...libraryUmdPresetWithTarget,\n ...componentPreset,\n ...componentPresetWithTarget,\n ...componentUmdPreset,\n ...componentUmdPresetWithTarget,\n 'modern-js-node': nodeBuildConfig,\n 'modern-js-universal': universalBuildConfig,\n};\n\nexport const BuildInPreset = {\n BASE_CONFIG: basePresetConfig,\n 'base-config': basePresetConfig,\n NPM_LIBRARY: npmLibraryPresetConfig,\n 'npm-library': npmLibraryPresetConfig,\n NPM_LIBRARY_WITH_UMD: npmLibraryWithUmdPresetConfig,\n 'npm-library-with-umd': npmLibraryWithUmdPresetConfig,\n NPM_COMPONENT: npmComponentPresetConfig,\n 'npm-component': npmComponentPresetConfig,\n NPM_COMPONENT_WITH_UMD: npmComponentWithUmdPresetConfig,\n 'npm-component-with-umd': npmComponentWithUmdPresetConfig,\n 'modern-js-node': nodeBuildConfig,\n 'modern-js-universal': universalBuildConfig,\n};\n"]}
|
package/dist/dev.js
CHANGED
|
@@ -25,14 +25,35 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
25
|
mod
|
|
26
26
|
));
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var __async = (__this, __arguments, generator) => {
|
|
29
|
+
return new Promise((resolve, reject) => {
|
|
30
|
+
var fulfilled = (value) => {
|
|
31
|
+
try {
|
|
32
|
+
step(generator.next(value));
|
|
33
|
+
} catch (e) {
|
|
34
|
+
reject(e);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var rejected = (value) => {
|
|
38
|
+
try {
|
|
39
|
+
step(generator.throw(value));
|
|
40
|
+
} catch (e) {
|
|
41
|
+
reject(e);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
45
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
46
|
+
});
|
|
47
|
+
};
|
|
28
48
|
var dev_exports = {};
|
|
29
49
|
__export(dev_exports, {
|
|
30
50
|
dev: () => dev,
|
|
31
51
|
showMenu: () => showMenu
|
|
32
52
|
});
|
|
33
53
|
module.exports = __toCommonJS(dev_exports);
|
|
34
|
-
|
|
35
|
-
|
|
54
|
+
var import_logger = require("@modern-js/utils/logger");
|
|
55
|
+
const showMenu = (metas, devCmdOptions, api, context) => __async(void 0, null, function* () {
|
|
56
|
+
const { chalk, inquirer } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
36
57
|
const runner = api.useHookRunners();
|
|
37
58
|
const menuTitle = chalk.rgb(255, 153, 0);
|
|
38
59
|
const choices = metas.map((meta) => meta.menuItem).filter((menuItem) => typeof menuItem === "object");
|
|
@@ -44,46 +65,50 @@ const showMenu = async (metas, devCmdOptions, api, context) => {
|
|
|
44
65
|
choices
|
|
45
66
|
}
|
|
46
67
|
];
|
|
47
|
-
const newQuestions =
|
|
48
|
-
const result =
|
|
68
|
+
const newQuestions = yield runner.beforeDevMenu(questions);
|
|
69
|
+
const result = yield inquirer.prompt(
|
|
49
70
|
newQuestions.length !== 0 ? newQuestions : questions
|
|
50
71
|
);
|
|
51
|
-
|
|
72
|
+
yield runner.afterDevMenu({ result, devTools: metas });
|
|
52
73
|
const currentDevTool = metas.find(
|
|
53
|
-
(meta) =>
|
|
74
|
+
(meta) => {
|
|
75
|
+
var _a;
|
|
76
|
+
return ((_a = meta.menuItem) == null ? void 0 : _a.value) === result.choiceDevTool;
|
|
77
|
+
}
|
|
54
78
|
);
|
|
55
79
|
if (currentDevTool) {
|
|
56
|
-
|
|
57
|
-
|
|
80
|
+
yield runner.beforeDevTask(currentDevTool);
|
|
81
|
+
yield currentDevTool.action(devCmdOptions, {
|
|
58
82
|
isTsProject: context.isTsProject
|
|
59
83
|
});
|
|
60
84
|
}
|
|
61
|
-
};
|
|
62
|
-
const dev =
|
|
63
|
-
|
|
64
|
-
const {
|
|
85
|
+
});
|
|
86
|
+
const dev = (options, metas, api, context) => __async(void 0, null, function* () {
|
|
87
|
+
var _a, _b;
|
|
88
|
+
const { chalk } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
89
|
+
const { green } = yield Promise.resolve().then(() => __toESM(require("./constants/colors")));
|
|
65
90
|
const runner = api.useHookRunners();
|
|
66
91
|
if (metas.length === 0) {
|
|
67
|
-
const local =
|
|
68
|
-
const noDevToolsLog =
|
|
92
|
+
const local = yield Promise.resolve().then(() => __toESM(require("./locale")));
|
|
93
|
+
const noDevToolsLog = yield runner.noDevTools(
|
|
69
94
|
local.i18n.t(local.localeKeys.log.dev.noDevtools)
|
|
70
95
|
);
|
|
71
|
-
|
|
96
|
+
import_logger.logger.info(noDevToolsLog);
|
|
72
97
|
process.exit(0);
|
|
73
98
|
}
|
|
74
99
|
if (metas.length === 1) {
|
|
75
|
-
|
|
100
|
+
import_logger.logger.info(
|
|
76
101
|
chalk.rgb(...green)(
|
|
77
|
-
`Only one dev tooling is currently detected as available, run it directly [${metas[0].menuItem
|
|
102
|
+
`Only one dev tooling is currently detected as available, run it directly [${(_b = (_a = metas[0].menuItem) == null ? void 0 : _a.name) != null ? _b : metas[0].name}]`
|
|
78
103
|
)
|
|
79
104
|
);
|
|
80
105
|
const meta = metas[0];
|
|
81
|
-
|
|
82
|
-
|
|
106
|
+
yield runner.beforeDevTask(meta);
|
|
107
|
+
yield meta.action(options, { isTsProject: context.isTsProject });
|
|
83
108
|
} else if (metas.length > 1) {
|
|
84
|
-
|
|
109
|
+
yield showMenu(metas, options, api, context);
|
|
85
110
|
}
|
|
86
|
-
};
|
|
111
|
+
});
|
|
87
112
|
// Annotate the CommonJS export names for ESM import in node:
|
|
88
113
|
0 && (module.exports = {
|
|
89
114
|
dev,
|
package/dist/dev.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":"
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAAuB;AAwChB,MAAM,WAAW,CACtB,OACA,eACA,KACA,YACG;AACH,QAAM,EAAE,OAAO,SAAS,IAAI,MAAM,6CAAO,kBAAkB;AAC3D,QAAM,SAAS,IAAI,eAAe;AAElC,QAAM,YAAY,MAAM,IAAI,KAAK,KAAK,CAAC;AACvC,QAAM,UAAU,MACb,IAAI,UAAQ,KAAK,QAAQ,EACzB,OAAO,cAAY,OAAO,aAAa,QAAQ;AAClD,QAAM,YAAY;AAAA,IAChB;AAAA,MACE,MAAM;AAAA,MACN,SAAS,UAAU,QAAQ;AAAA,MAC3B,MAAM;AAAA,MACN;AAAA,IACF;AAAA,EACF;AAEA,QAAM,eAAe,MAAM,OAAO,cAAc,SAAS;AACzD,QAAM,SAAoC,MAAM,SAAS;AAAA,IACvD,aAAa,WAAW,IAAI,eAAe;AAAA,EAC7C;AACA,QAAM,OAAO,aAAa,EAAE,QAAQ,UAAU,MAAM,CAAC;AAErD,QAAM,iBAAiB,MAAM;AAAA,IAC3B,UAAK;AAtET;AAsEY,yBAAK,aAAL,mBAAe,WAAU,OAAO;AAAA;AAAA,EAC1C;AACA,MAAI,gBAAgB;AAOlB,UAAM,OAAO,cAAc,cAAc;AACzC,UAAM,eAAe,OAAO,eAAe;AAAA,MACzC,aAAa,QAAQ;AAAA,IACvB,CAAC;AAAA,EAOH;AACF;AAEO,MAAM,MAAM,CACjB,SACA,OACA,KACA,YACG;AAjGL;AAkGE,QAAM,EAAE,MAAM,IAAI,MAAM,6CAAO,kBAAkB;AACjD,QAAM,EAAE,MAAM,IAAI,MAAM,6CAAO,oBAAoB;AACnD,QAAM,SAAS,IAAI,eAAe;AAClC,MAAI,MAAM,WAAW,GAAG;AACtB,UAAM,QAAQ,MAAM,6CAAO,UAAU;AACrC,UAAM,gBAAgB,MAAM,OAAO;AAAA,MACjC,MAAM,KAAK,EAAE,MAAM,WAAW,IAAI,IAAI,UAAU;AAAA,IAClD;AAEA,yBAAO,KAAK,aAAa;AAEzB,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,MAAI,MAAM,WAAW,GAAG;AACtB,yBAAO;AAAA,MACL,MAAM,IAAI,GAAG,KAAK;AAAA,QAChB,8EACE,iBAAM,CAAC,EAAE,aAAT,mBAAmB,SAAnB,YAA2B,MAAM,CAAC,EAAE;AAAA,MAExC;AAAA,IACF;AACA,UAAM,OAAO,MAAM,CAAC;AAQpB,UAAM,OAAO,cAAc,IAAI;AAC/B,UAAM,KAAK,OAAO,SAAS,EAAE,aAAa,QAAQ,YAAY,CAAC;AAAA,EAMjE,WAAW,MAAM,SAAS,GAAG;AAC3B,UAAM,SAAS,OAAO,SAAS,KAAK,OAAO;AAAA,EAC7C;AACF;;;;;;","names":[],"sources":["../src/dev.ts"],"sourcesContent":["import type { PluginAPI } from '@modern-js/core';\nimport { logger } from '@modern-js/utils/logger';\nimport type { DevCommandOptions } from './types/command';\nimport type { ModuleContext } from './types/context';\nimport type { DevToolData, ModuleTools } from './types';\n\n// TODO: watch build\n// export const ensureFirstBuild = async (\n// api: PluginAPI<ModuleTools>,\n// context: ModuleContext,\n// cliOptions: DevCommandOptions,\n// options: {\n// watch?: boolean;\n// disableRunBuild: boolean;\n// appDirectory: string;\n// },\n// ) => {\n// if (!options.disableRunBuild) {\n// const { build } = await import('./build');\n// const defaultCmdOptions: BuildCommandOptions = {\n// tsconfig: cliOptions.tsconfig,\n// watch: options.watch ?? false,\n// dts: true,\n// clear: true,\n// };\n// await build(api, defaultCmdOptions, context);\n// }\n// };\n\n// export const watchBuild = async (\n// api: PluginAPI<ModuleTools>,\n// context: ModuleContext,\n// cliOptions: DevCommandOptions,\n// options: {\n// disableRunBuild: boolean;\n// appDirectory: string;\n// },\n// ) => {\n// await ensureFirstBuild(api, context, cliOptions, { ...options, watch: true });\n// };\n\nexport const showMenu = async (\n metas: DevToolData[],\n devCmdOptions: DevCommandOptions,\n api: PluginAPI<ModuleTools>,\n context: ModuleContext,\n) => {\n const { chalk, inquirer } = await import('@modern-js/utils');\n const runner = api.useHookRunners();\n\n const menuTitle = chalk.rgb(255, 153, 0);\n const choices = metas\n .map(meta => meta.menuItem)\n .filter(menuItem => typeof menuItem === 'object');\n const questions = [\n {\n name: 'choiceDevTool',\n message: menuTitle('选择调试工具'),\n type: 'list',\n choices,\n },\n ];\n\n const newQuestions = await runner.beforeDevMenu(questions);\n const result: { choiceDevTool: string } = await inquirer.prompt(\n newQuestions.length !== 0 ? newQuestions : questions,\n );\n await runner.afterDevMenu({ result, devTools: metas });\n\n const currentDevTool = metas.find(\n meta => meta.menuItem?.value === result.choiceDevTool,\n );\n if (currentDevTool) {\n // TODO: watch build\n // await ensureFirstBuild(api, context, devCmdOptions, {\n // disableRunBuild: currentDevTool.disableRunBuild ?? false,\n // appDirectory: context.appDirectory,\n // });\n\n await runner.beforeDevTask(currentDevTool);\n await currentDevTool.action(devCmdOptions, {\n isTsProject: context.isTsProject,\n });\n\n // TODO: watch build\n // await watchBuild(api, context, devCmdOptions, {\n // disableRunBuild: currentDevTool.disableRunBuild ?? false,\n // appDirectory: context.appDirectory,\n // });\n }\n};\n\nexport const dev = async (\n options: DevCommandOptions,\n metas: DevToolData[],\n api: PluginAPI<ModuleTools>,\n context: ModuleContext,\n) => {\n const { chalk } = await import('@modern-js/utils');\n const { green } = await import('./constants/colors');\n const runner = api.useHookRunners();\n if (metas.length === 0) {\n const local = await import('./locale');\n const noDevToolsLog = await runner.noDevTools(\n local.i18n.t(local.localeKeys.log.dev.noDevtools),\n );\n\n logger.info(noDevToolsLog);\n // eslint-disable-next-line no-process-exit\n process.exit(0);\n }\n\n if (metas.length === 1) {\n logger.info(\n chalk.rgb(...green)(\n `Only one dev tooling is currently detected as available, run it directly [${\n metas[0].menuItem?.name ?? metas[0].name\n }]`,\n ),\n );\n const meta = metas[0];\n\n // TODO: watch build\n // await ensureFirstBuild(api, context, options, {\n // disableRunBuild: meta.disableRunBuild ?? false,\n // appDirectory: context.appDirectory,\n // });\n\n await runner.beforeDevTask(meta);\n await meta.action(options, { isTsProject: context.isTsProject });\n // TODO: watch build\n // await watchBuild(api, context, options, {\n // disableRunBuild: meta.disableRunBuild ?? false,\n // appDirectory: context.appDirectory,\n // });\n } else if (metas.length > 1) {\n await showMenu(metas, options, api, context);\n }\n};\n"]}
|
package/dist/error.js
CHANGED
|
@@ -44,10 +44,6 @@ const padSpaceWith = (str, targetL, opts = {}) => {
|
|
|
44
44
|
return str;
|
|
45
45
|
};
|
|
46
46
|
class InternalBuildError extends Error {
|
|
47
|
-
buildType;
|
|
48
|
-
target;
|
|
49
|
-
format;
|
|
50
|
-
e;
|
|
51
47
|
constructor(e, opts) {
|
|
52
48
|
super(e.message);
|
|
53
49
|
Error.captureStackTrace(this, this.constructor);
|
|
@@ -94,8 +90,6 @@ Detailed Information: `)
|
|
|
94
90
|
}
|
|
95
91
|
}
|
|
96
92
|
class InternalDTSError extends Error {
|
|
97
|
-
buildType;
|
|
98
|
-
e;
|
|
99
93
|
constructor(e, opts) {
|
|
100
94
|
super(e.message);
|
|
101
95
|
Error.captureStackTrace(this, this.constructor);
|
|
@@ -106,12 +100,13 @@ class InternalDTSError extends Error {
|
|
|
106
100
|
return this.formatError().join("\n");
|
|
107
101
|
}
|
|
108
102
|
formatError() {
|
|
103
|
+
var _a;
|
|
109
104
|
const msgs = [];
|
|
110
105
|
const { e, buildType } = this;
|
|
111
106
|
msgs.push(import_utils.chalk.red.bold(`${buildType} DTS failed:`));
|
|
112
107
|
if (isExecaError(e)) {
|
|
113
108
|
if (e.stack) {
|
|
114
|
-
msgs.push(e.stack
|
|
109
|
+
msgs.push((_a = e.stack) == null ? void 0 : _a.replace(`${e.name}: ${e.shortMessage}`, ""));
|
|
115
110
|
}
|
|
116
111
|
} else {
|
|
117
112
|
msgs.push(e.stack);
|
package/dist/error.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAsB;AAIf,MAAM,eAAe,CAC1B,KACA,SACA,OAGI,CAAC,MACF;AACH,QAAM,EAAE,SAAS,KAAK,MAAM,IAAI;AAChC,QAAM,IAAI,IAAI;AACd,QAAM,UAAU,OAAO;AACvB,QAAM,SAAS,UAAU,IAAI;AAG7B,MAAI,WAAW,GAAG;AAChB,YAAQ,QAAQ,MAAM,GAAG,IAAI,OAAO;AAAA,EACtC;AAGA,MAAI,SAAS,GAAG;AACd,UAAM,SAAS,IAAI,OAAO,UAAU,GAAG,GAAG;AAC1C,QAAI,OAAO;AACT,aAAO,MAAM,GAAG,IAAI,OAAO,QAAQ,KAAK,EAAE,IAAI;AAAA,IAChD;AACA,WAAO,SAAS;AAAA,EAClB;AAEA,SAAO;AACT;AAEO,MAAM,2BAA2B,MAAM;AAAA,
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAEO,MAAM,eAAe,CAAC,MAA4B;AACvD,MAAI,EAAE,QAAQ;AACZ,WAAO;AAAA,EACT;AAEA,SAAO;AACT;;;;;;;;;;","names":[],"sources":["../src/error.ts"],"sourcesContent":["import { chalk } from '@modern-js/utils';\nimport type { ExecaError } from '@modern-js/utils';\nimport type { BuildType, Format, Target } from './types';\n\nexport const padSpaceWith = (\n str: string,\n targetL: number,\n opts: {\n endStr?: string;\n style?: (s: string) => string;\n } = {},\n) => {\n const { endStr = '|', style } = opts;\n const l = str.length;\n const endStrL = endStr.length;\n const resetL = targetL - l - endStrL;\n\n // str is 'aaa', targetL is 4, result is 'aaa|'\n if (resetL === 0) {\n return (style ? style(str) : str) + endStr;\n }\n\n // str is 'aaa', targetL is 5, result is 'aaa |'\n if (resetL > 0) {\n const padStr = str.padEnd(targetL - 1, ' ');\n if (style) {\n return style(str) + padStr.replace(str, '') + endStr;\n }\n return padStr + endStr;\n }\n\n return str;\n};\n\nexport class InternalBuildError extends Error {\n public buildType: BuildType;\n\n public target: Target;\n\n public format: Format;\n\n private e: Error;\n\n constructor(\n e: Error,\n opts: {\n buildType: BuildType;\n format: Format;\n target: Target;\n },\n ) {\n super(e.message);\n\n Error.captureStackTrace(this, this.constructor);\n\n this.e = e;\n this.buildType = opts.buildType;\n this.target = opts.target;\n this.format = opts.format;\n }\n\n toString() {\n return this.formatError().join('\\n');\n }\n\n formatError() {\n const msgs: string[] = [];\n const { e, buildType, target, format } = this;\n const textL = 25;\n const title = `│ ${padSpaceWith(`${buildType} failed:`, textL - 2, {\n style: chalk.red.underline,\n endStr: '│',\n })}`;\n const formatMsg = padSpaceWith(`│ - format is \"${format}\"`, textL, {\n endStr: '│',\n });\n const targetMsg = padSpaceWith(`│ - target is \"${target}\"`, textL, {\n endStr: '│',\n });\n const startLine = padSpaceWith('╭'.padEnd(textL - 1, '─'), textL, {\n endStr: '╮',\n });\n const endLine = padSpaceWith('╰'.padEnd(textL - 1, '─'), textL, {\n endStr: '╯',\n });\n msgs.push(\n startLine,\n title,\n formatMsg,\n targetMsg,\n endLine,\n chalk.blue.bold.underline(`\\nDetailed Information: `),\n );\n msgs.push(e.toString());\n msgs.push(e.stack || '');\n\n return msgs;\n }\n}\n\nexport class InternalDTSError extends Error {\n public buildType: BuildType;\n\n private e: Error;\n\n constructor(e: Error | ExecaError, opts: { buildType: BuildType }) {\n super(e.message);\n\n Error.captureStackTrace(this, this.constructor);\n\n this.e = e;\n this.buildType = opts.buildType;\n }\n\n toString() {\n return this.formatError().join('\\n');\n }\n\n formatError() {\n const msgs: string[] = [];\n const { e, buildType } = this;\n msgs.push(chalk.red.bold(`${buildType} DTS failed:`));\n if (isExecaError(e)) {\n /**\n * `shortMeessage` content like:\n * 'Command failed with exit code 2: /Users/github/modern.js/playground/module/node_modules/.bin/tsc -p /Users/github/modern.js/playground/module/node_modules/tsconfig.temp.json --pretty'\n * Don`t need it.\n */\n if (e.stack) {\n msgs.push(e.stack?.replace(`${e.name}: ${e.shortMessage}`, ''));\n }\n } else {\n msgs.push(e.stack!);\n }\n\n return msgs;\n }\n}\n\nexport class ModuleBuildError extends Error {\n constructor(e: InternalBuildError | InternalDTSError) {\n super(`\\n\\n${e}`);\n Error.captureStackTrace(this, this.constructor);\n this.name = 'ModuleBuildError';\n }\n}\n\nexport const isInternalError = (\n e: unknown,\n): e is InternalDTSError | InternalBuildError => {\n if (e instanceof InternalBuildError || e instanceof InternalDTSError) {\n return true;\n }\n\n return false;\n};\n\nexport const isExecaError = (e: any): e is ExecaError => {\n if (e.stdout) {\n return true;\n }\n\n return false;\n};\n"]}
|
package/dist/hooks/index.js
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
4
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
5
19
|
var __export = (target, all) => {
|
|
6
20
|
for (var name in all)
|
|
7
21
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -23,12 +37,7 @@ module.exports = __toCommonJS(hooks_exports);
|
|
|
23
37
|
var import_build = require("./build");
|
|
24
38
|
var import_dev = require("./dev");
|
|
25
39
|
var import_misc = require("./misc");
|
|
26
|
-
const registerHook = {
|
|
27
|
-
...import_build.buildHooks,
|
|
28
|
-
...import_dev.devHooks,
|
|
29
|
-
...import_misc.miscHooks,
|
|
30
|
-
...import_build.buildWatchHooks
|
|
31
|
-
};
|
|
40
|
+
const registerHook = __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, import_build.buildHooks), import_dev.devHooks), import_misc.miscHooks), import_build.buildWatchHooks);
|
|
32
41
|
// Annotate the CommonJS export names for ESM import in node:
|
|
33
42
|
0 && (module.exports = {
|
|
34
43
|
registerHook
|
package/dist/hooks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":"
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA4C;AAC5C,iBAAyB;AACzB,kBAA0B;AAEnB,MAAM,eAAe,gEACvB,0BACA,sBACA,wBACA;;;;;","names":[],"sources":["../../src/hooks/index.ts"],"sourcesContent":["import { buildHooks, buildWatchHooks } from './build';\nimport { devHooks } from './dev';\nimport { miscHooks } from './misc';\n\nexport const registerHook = {\n ...buildHooks,\n ...devHooks,\n ...miscHooks,\n ...buildWatchHooks,\n};\n"]}
|
package/dist/locale/en.d.ts
CHANGED
package/dist/locale/en.js
CHANGED
|
@@ -21,9 +21,8 @@ __export(en_exports, {
|
|
|
21
21
|
});
|
|
22
22
|
module.exports = __toCommonJS(en_exports);
|
|
23
23
|
var import_utils = require("@modern-js/utils");
|
|
24
|
-
const noDevTools = `
|
|
25
|
-
|
|
26
|
-
- ${import_utils.chalk.underline(
|
|
24
|
+
const noDevTools = `There are no DevTools available, you can learn about them and choose to use them by following the link options.
|
|
25
|
+
- ${import_utils.chalk.underline(
|
|
27
26
|
import_utils.chalk.blue("[Storybook]"),
|
|
28
27
|
"https://modernjs.dev/module-tools/guide/basic/using-storybook.html"
|
|
29
28
|
)}
|
|
@@ -58,6 +57,9 @@ const EN_LOCALE = {
|
|
|
58
57
|
dev: {
|
|
59
58
|
noDevtools: noDevTools
|
|
60
59
|
}
|
|
60
|
+
},
|
|
61
|
+
dts: {
|
|
62
|
+
abortOnError: "`dts.abortOnError` currently enabled, type errors don`t cause build failures. Unable to ensure proper type file generation"
|
|
61
63
|
}
|
|
62
64
|
};
|
|
63
65
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/locale/en.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAsB;AAEtB,MAAM,aAAa;AAAA
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAsB;AAEtB,MAAM,aAAa;AAAA,MACb,mBAAM;AAAA,EACR,mBAAM,KAAK,aAAa;AAAA,EACxB;AACF;AAAA;AAGK,MAAM,YAAY;AAAA,EACvB,SAAS;AAAA,IACP,OAAO;AAAA,MACL,UAAU;AAAA,MACV,OAAO;AAAA,MACP,UAAU;AAAA,MACV,WAAW;AAAA,MACX,UACE;AAAA,MACF,OAAO;AAAA,MACP,KAAK;AAAA,MACL,SAAS;AAAA,MACT,QAAQ;AAAA,IACV;AAAA,IACA,KAAK;AAAA,MACH,UAAU;AAAA,MACV,UAAU;AAAA,IACZ;AAAA,IACA,KAAK;AAAA,MACH,UAAU;AAAA,MACV,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,UAAU;AAAA,MACV,MAAM;AAAA,IACR;AAAA,EACF;AAAA,EACA,KAAK;AAAA,IACH,KAAK;AAAA,MACH,YAAY;AAAA,IACd;AAAA,EACF;AAAA,EACA,KAAK;AAAA,IACH,cACE;AAAA,EACJ;AACF;;;;;","names":[],"sources":["../../src/locale/en.ts"],"sourcesContent":["import { chalk } from '@modern-js/utils';\n\nconst noDevTools = `There are no DevTools available, you can learn about them and choose to use them by following the link options.\n - ${chalk.underline(\n chalk.blue('[Storybook]'),\n 'https://modernjs.dev/module-tools/guide/basic/using-storybook.html',\n )}\n`;\n\nexport const EN_LOCALE = {\n command: {\n build: {\n describe: 'command for building module',\n watch: 'building module in watch mode',\n tsconfig: 'Specify a path to the tsconfig.json file',\n styleOnly: 'only build style',\n platform:\n 'build the specified task or all tasks, If exist. (tasks: \"storybook\", \"docs\")',\n noTsc: 'close tsc compiler to emit d.ts (Deprecated)',\n dts: 'Turn on dts generation and type checking',\n noClear: 'disable auto clear dist dir',\n config: 'specify config file',\n },\n dev: {\n describe: 'start dev server',\n tsconfig: 'Specify a path to the tsconfig.json file',\n },\n new: {\n describe: 'generator runner for modern project',\n debug: 'using debug mode to log something',\n config: 'set default generator config(json string)',\n distTag: `use specified tag version for it's generator`,\n registry: 'set npm registry url to run npm command',\n lang: 'set new command language(en or zh)',\n },\n },\n log: {\n dev: {\n noDevtools: noDevTools,\n },\n },\n dts: {\n abortOnError:\n '`dts.abortOnError` currently enabled, type errors don`t cause build failures. Unable to ensure proper type file generation',\n },\n};\n"]}
|
package/dist/locale/index.d.ts
CHANGED
|
@@ -30,6 +30,9 @@ declare const localeKeys: {
|
|
|
30
30
|
noDevtools: string;
|
|
31
31
|
};
|
|
32
32
|
};
|
|
33
|
+
dts: {
|
|
34
|
+
abortOnError: string;
|
|
35
|
+
};
|
|
33
36
|
} | {
|
|
34
37
|
command: {
|
|
35
38
|
build: {
|
|
@@ -61,5 +64,8 @@ declare const localeKeys: {
|
|
|
61
64
|
noDevtools: string;
|
|
62
65
|
};
|
|
63
66
|
};
|
|
67
|
+
dts: {
|
|
68
|
+
abortOnError: string;
|
|
69
|
+
};
|
|
64
70
|
};
|
|
65
71
|
export { i18n, localeKeys };
|
package/dist/locale/zh.d.ts
CHANGED
package/dist/locale/zh.js
CHANGED
|
@@ -21,9 +21,8 @@ __export(zh_exports, {
|
|
|
21
21
|
});
|
|
22
22
|
module.exports = __toCommonJS(zh_exports);
|
|
23
23
|
var import_utils = require("@modern-js/utils");
|
|
24
|
-
const noDevTools =
|
|
25
|
-
|
|
26
|
-
- ${import_utils.chalk.underline(
|
|
24
|
+
const noDevTools = `暂无可用的 DevTools,你可以通过以下选项以及对应的链接来了解如何使用。
|
|
25
|
+
- ${import_utils.chalk.underline(
|
|
27
26
|
import_utils.chalk.blue("[Storybook]:"),
|
|
28
27
|
"https://modernjs.dev/module-tools/guide/basic/using-storybook.html"
|
|
29
28
|
)}
|
|
@@ -58,6 +57,9 @@ const ZH_LOCALE = {
|
|
|
58
57
|
dev: {
|
|
59
58
|
noDevtools: noDevTools
|
|
60
59
|
}
|
|
60
|
+
},
|
|
61
|
+
dts: {
|
|
62
|
+
abortOnError: "当前开启了 `dts.abortOnError` 配置,类型错误不会导致构建失败,无法保证类型文件正常输出"
|
|
61
63
|
}
|
|
62
64
|
};
|
|
63
65
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/locale/zh.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAsB;AAEtB,MAAM,aAAa;AAAA
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAsB;AAEtB,MAAM,aAAa;AAAA,MACb,mBAAM;AAAA,EACR,mBAAM,KAAK,cAAc;AAAA,EACzB;AACF;AAAA;AAGK,MAAM,YAAY;AAAA,EACvB,SAAS;AAAA,IACP,OAAO;AAAA,MACL,UAAU;AAAA,MACV,OAAO;AAAA,MACP,UAAU;AAAA,MACV,WAAW;AAAA,MACX,UACE;AAAA,MACF,OAAO;AAAA,MACP,KAAK;AAAA,MACL,SAAS;AAAA,MACT,QAAQ;AAAA,IACV;AAAA,IACA,KAAK;AAAA,MACH,UAAU;AAAA,MACV,UAAU;AAAA,IACZ;AAAA,IACA,KAAK;AAAA,MACH,UAAU;AAAA,MACV,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,UAAU;AAAA,MACV,MAAM;AAAA,IACR;AAAA,EACF;AAAA,EACA,KAAK;AAAA,IACH,KAAK;AAAA,MACH,YAAY;AAAA,IACd;AAAA,EACF;AAAA,EACA,KAAK;AAAA,IACH,cACE;AAAA,EACJ;AACF;;;;;","names":[],"sources":["../../src/locale/zh.ts"],"sourcesContent":["import { chalk } from '@modern-js/utils';\n\nconst noDevTools = `暂无可用的 DevTools,你可以通过以下选项以及对应的链接来了解如何使用。\n - ${chalk.underline(\n chalk.blue('[Storybook]:'),\n 'https://modernjs.dev/module-tools/guide/basic/using-storybook.html',\n )}\n`;\n\nexport const ZH_LOCALE = {\n command: {\n build: {\n describe: '构建模块命令',\n watch: '使用 Watch 模式构建模块',\n tsconfig: '指定 tsconfig.json 文件的路径',\n styleOnly: '只构建样式文件',\n platform:\n '如果存在的话,执行指定的构建任务或者全部构建任务. (构建任务包括: \"storybook\", \"文档\")',\n noTsc: '关闭 tsc 编译(废弃)',\n dts: '开启 dts 文件的生成以及类型检查',\n noClear: '不清理产物目录',\n config: '指定配置文件路径,可以为相对路径或绝对路径',\n },\n dev: {\n describe: '本地开发命令',\n tsconfig: '指定 tsconfig.json 文件的路径',\n },\n new: {\n describe: '模块化工程方案中执行生成器',\n debug: '开启 Debug 模式,打印调试日志信息',\n config: '生成器运行默认配置(JSON 字符串)',\n distTag: '生成器使用特殊的 npm Tag 版本',\n registry: '生成器运行过程中定制 npm Registry',\n lang: '设置 new 命令执行语言(zh 或者 en)',\n },\n },\n log: {\n dev: {\n noDevtools: noDevTools,\n },\n },\n dts: {\n abortOnError:\n '当前开启了 `dts.abortOnError` 配置,类型错误不会导致构建失败,无法保证类型文件正常输出',\n },\n};\n"]}
|
|
@@ -10,6 +10,7 @@ export type Format = 'esm' | 'cjs' | 'umd' | 'iife';
|
|
|
10
10
|
export type Target = 'es5' | 'es6' | 'es2015' | 'es2016' | 'es2017' | 'es2018' | 'es2019' | 'es2020' | 'es2021' | 'es2022' | 'esnext';
|
|
11
11
|
export type Input = Required<LibuildUserConfig>['input'];
|
|
12
12
|
export type DTSOptions = {
|
|
13
|
+
abortOnError: boolean;
|
|
13
14
|
distPath: string;
|
|
14
15
|
tsconfigPath: string;
|
|
15
16
|
only: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;AAAA;AAAA;AAgBA,2BAAc,oBAhBd;","names":[],"sources":["../../../src/types/config/index.ts"],"sourcesContent":["import type {\n UserConfig as LibuildUserConfig,\n Asset as LibuildAsset,\n Style as LibuildStyle,\n} from '@modern-js/libuild';\nimport type { Options } from '@modern-js/libuild-plugin-svgr';\nimport type { ToolsConfig as WebpackBuilderToolsConfig } from '@modern-js/builder-webpack-provider';\nimport { BuildInPreset, presetList } from '../../constants/buildPresets';\nimport type { CopyConfig } from '../copy';\nimport type {\n LessConfig,\n SassConfig,\n PostCSSConfig,\n TailwindCSSConfig,\n} from './style';\n\nexport * from './style';\n\nexport type BuildType = 'bundleless' | 'bundle';\n\nexport type Format = 'esm' | 'cjs' | 'umd' | 'iife';\n\nexport type Target =\n | 'es5'\n | 'es6'\n | 'es2015'\n | 'es2016'\n | 'es2017'\n | 'es2018'\n | 'es2019'\n | 'es2020'\n | 'es2021'\n | 'es2022'\n // The default target is esnext which means that by default, assume all of the latest JavaScript and CSS features are supported.\n | 'esnext';\n\nexport type Input = Required<LibuildUserConfig>['input'];\n\nexport type DTSOptions = {\n distPath: string;\n tsconfigPath: string;\n only: boolean;\n};\nexport type DTS = false | Partial<DTSOptions>;\n\nexport interface Asset {\n path?: LibuildAsset['outdir'];\n limit?: LibuildAsset['limit'];\n publicPath?: LibuildAsset['publicPath'];\n svgr?: boolean | Options;\n}\nexport type SourceMap = Required<LibuildUserConfig>['sourceMap'];\nexport type AutoExternal =\n | boolean\n | {\n dependencies?: boolean;\n peerDependencies?: boolean;\n };\nexport type JSX = 'automatic' | 'transform';\n\nexport type AliasOption =\n | Record<string, string>\n | ((aliases: Record<string, string>) => Record<string, string> | void);\n\nexport type BaseBuildConfig = Omit<\n Required<PartialBaseBuildConfig>,\n 'dts' | 'style' | 'alias' | 'sideEffects'\n> & {\n sideEffects: LibuildUserConfig['sideEffects'];\n dts: false | DTSOptions;\n style: Omit<Required<LibuildStyle>, 'cleanCss'> & {\n tailwindCss: TailwindCSSConfig;\n };\n alias: Record<string, string>;\n};\n\nexport type PartialBaseBuildConfig = {\n buildType?: 'bundleless' | 'bundle';\n format?: Format;\n target?: Target;\n dts?: DTS;\n sourceMap?: SourceMap;\n sourceDir?: string;\n copy?: CopyConfig;\n asset?: Asset;\n jsx?: JSX;\n outDir?: string;\n alias?: AliasOption;\n input?: Input;\n metafile?: boolean;\n platform?: LibuildUserConfig['platform'];\n splitting?: LibuildUserConfig['splitting'];\n minify?: LibuildUserConfig['minify'];\n externals?: LibuildUserConfig['external'];\n autoExternal?: AutoExternal;\n umdGlobals?: LibuildUserConfig['globals'];\n umdModuleName?: ((chunkName: string) => string) | string | undefined;\n define?: LibuildUserConfig['define'];\n style?: StyleConfig;\n sideEffects?: LibuildUserConfig['sideEffects'];\n};\n\nexport type BuildConfig = BaseBuildConfig | BaseBuildConfig[];\nexport type PartialBuildConfig =\n | PartialBaseBuildConfig\n | PartialBaseBuildConfig[];\n\nexport type BuildPreset =\n | keyof typeof presetList\n | ((options: {\n preset: typeof BuildInPreset;\n extendPreset: (\n extendPresetName: keyof typeof BuildInPreset,\n extendBuildConfig: PartialBaseBuildConfig,\n ) => PartialBuildConfig;\n }) => PartialBuildConfig | Promise<PartialBuildConfig>);\n\nexport interface StyleConfig {\n less?: LessConfig;\n sass?: SassConfig;\n postcss?: PostCSSConfig;\n autoModules?: LibuildStyle['autoModules'];\n modules?: LibuildStyle['modules'];\n inject?: LibuildStyle['inject'];\n /**\n * The configuration of `tools.tailwindcss` is provided by `tailwindcss` plugin.\n * Please use `yarn new` or `pnpm new` to enable the corresponding capability.\n * @requires `tailwindcss` plugin\n */\n tailwindcss?: TailwindCSSConfig;\n}\n\nexport interface StorybookBuildConfig {\n webpack?: WebpackBuilderToolsConfig['webpack'];\n webpackChain?: WebpackBuilderToolsConfig['webpackChain'];\n}\nexport interface Dev {\n storybook?: StorybookBuildConfig;\n}\n\nexport interface RuntimeUserConfig {\n [name: string]: any;\n}\n\nexport interface ModuleExtraConfig {\n designSystem?: Record<string, any>;\n\n buildConfig?: PartialBuildConfig;\n\n buildPreset?: BuildPreset;\n\n dev?: Dev;\n\n runtime?: RuntimeUserConfig;\n}\n"]}
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;AAAA;AAAA;AAgBA,2BAAc,oBAhBd;","names":[],"sources":["../../../src/types/config/index.ts"],"sourcesContent":["import type {\n UserConfig as LibuildUserConfig,\n Asset as LibuildAsset,\n Style as LibuildStyle,\n} from '@modern-js/libuild';\nimport type { Options } from '@modern-js/libuild-plugin-svgr';\nimport type { ToolsConfig as WebpackBuilderToolsConfig } from '@modern-js/builder-webpack-provider';\nimport { BuildInPreset, presetList } from '../../constants/buildPresets';\nimport type { CopyConfig } from '../copy';\nimport type {\n LessConfig,\n SassConfig,\n PostCSSConfig,\n TailwindCSSConfig,\n} from './style';\n\nexport * from './style';\n\nexport type BuildType = 'bundleless' | 'bundle';\n\nexport type Format = 'esm' | 'cjs' | 'umd' | 'iife';\n\nexport type Target =\n | 'es5'\n | 'es6'\n | 'es2015'\n | 'es2016'\n | 'es2017'\n | 'es2018'\n | 'es2019'\n | 'es2020'\n | 'es2021'\n | 'es2022'\n // The default target is esnext which means that by default, assume all of the latest JavaScript and CSS features are supported.\n | 'esnext';\n\nexport type Input = Required<LibuildUserConfig>['input'];\n\nexport type DTSOptions = {\n abortOnError: boolean;\n distPath: string;\n tsconfigPath: string;\n only: boolean;\n};\nexport type DTS = false | Partial<DTSOptions>;\n\nexport interface Asset {\n path?: LibuildAsset['outdir'];\n limit?: LibuildAsset['limit'];\n publicPath?: LibuildAsset['publicPath'];\n svgr?: boolean | Options;\n}\nexport type SourceMap = Required<LibuildUserConfig>['sourceMap'];\nexport type AutoExternal =\n | boolean\n | {\n dependencies?: boolean;\n peerDependencies?: boolean;\n };\nexport type JSX = 'automatic' | 'transform';\n\nexport type AliasOption =\n | Record<string, string>\n | ((aliases: Record<string, string>) => Record<string, string> | void);\n\nexport type BaseBuildConfig = Omit<\n Required<PartialBaseBuildConfig>,\n 'dts' | 'style' | 'alias' | 'sideEffects'\n> & {\n sideEffects: LibuildUserConfig['sideEffects'];\n dts: false | DTSOptions;\n style: Omit<Required<LibuildStyle>, 'cleanCss'> & {\n tailwindCss: TailwindCSSConfig;\n };\n alias: Record<string, string>;\n};\n\nexport type PartialBaseBuildConfig = {\n buildType?: 'bundleless' | 'bundle';\n format?: Format;\n target?: Target;\n dts?: DTS;\n sourceMap?: SourceMap;\n sourceDir?: string;\n copy?: CopyConfig;\n asset?: Asset;\n jsx?: JSX;\n outDir?: string;\n alias?: AliasOption;\n input?: Input;\n metafile?: boolean;\n platform?: LibuildUserConfig['platform'];\n splitting?: LibuildUserConfig['splitting'];\n minify?: LibuildUserConfig['minify'];\n externals?: LibuildUserConfig['external'];\n autoExternal?: AutoExternal;\n umdGlobals?: LibuildUserConfig['globals'];\n umdModuleName?: ((chunkName: string) => string) | string | undefined;\n define?: LibuildUserConfig['define'];\n style?: StyleConfig;\n sideEffects?: LibuildUserConfig['sideEffects'];\n};\n\nexport type BuildConfig = BaseBuildConfig | BaseBuildConfig[];\nexport type PartialBuildConfig =\n | PartialBaseBuildConfig\n | PartialBaseBuildConfig[];\n\nexport type BuildPreset =\n | keyof typeof presetList\n | ((options: {\n preset: typeof BuildInPreset;\n extendPreset: (\n extendPresetName: keyof typeof BuildInPreset,\n extendBuildConfig: PartialBaseBuildConfig,\n ) => PartialBuildConfig;\n }) => PartialBuildConfig | Promise<PartialBuildConfig>);\n\nexport interface StyleConfig {\n less?: LessConfig;\n sass?: SassConfig;\n postcss?: PostCSSConfig;\n autoModules?: LibuildStyle['autoModules'];\n modules?: LibuildStyle['modules'];\n inject?: LibuildStyle['inject'];\n /**\n * The configuration of `tools.tailwindcss` is provided by `tailwindcss` plugin.\n * Please use `yarn new` or `pnpm new` to enable the corresponding capability.\n * @requires `tailwindcss` plugin\n */\n tailwindcss?: TailwindCSSConfig;\n}\n\nexport interface StorybookBuildConfig {\n webpack?: WebpackBuilderToolsConfig['webpack'];\n webpackChain?: WebpackBuilderToolsConfig['webpackChain'];\n}\nexport interface Dev {\n storybook?: StorybookBuildConfig;\n}\n\nexport interface RuntimeUserConfig {\n [name: string]: any;\n}\n\nexport interface ModuleExtraConfig {\n designSystem?: Record<string, any>;\n\n buildConfig?: PartialBuildConfig;\n\n buildPreset?: BuildPreset;\n\n dev?: Dev;\n\n runtime?: RuntimeUserConfig;\n}\n"]}
|
package/dist/types/dts.d.ts
CHANGED
package/dist/types/dts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"mappings":";;;;;;;;;;;;;AAAA;AAAA;","names":[],"sources":["../../src/types/dts.ts"],"sourcesContent":["import type { AliasOption } from './config';\n\nexport interface BundlelessGeneratorDtsConfig {\n appDirectory: string;\n distAbsPath: string;\n tsconfigPath: string;\n watch: boolean;\n sourceDir: string;\n alias: AliasOption;\n}\n\nexport interface ITsconfig {\n compilerOptions?:\n | {\n rootDir?: string;\n baseUrl?: string;\n declaration?: boolean;\n emitDeclarationOnly?: boolean;\n emitDecoratorMetadata?: boolean;\n isolatedModules?: boolean;\n allowJs?: boolean;\n outDir?: string;\n paths?: Record<string, string[]>;\n }\n | undefined;\n include?: string[];\n exclude?: string[];\n extends?: string;\n}\n"]}
|
|
1
|
+
{"version":3,"mappings":";;;;;;;;;;;;;AAAA;AAAA;","names":[],"sources":["../../src/types/dts.ts"],"sourcesContent":["import type { AliasOption } from './config';\n\nexport interface BundlelessGeneratorDtsConfig {\n appDirectory: string;\n distAbsPath: string;\n tsconfigPath: string;\n watch: boolean;\n sourceDir: string;\n alias: AliasOption;\n abortOnError?: boolean;\n}\n\nexport interface ITsconfig {\n compilerOptions?:\n | {\n rootDir?: string;\n baseUrl?: string;\n declaration?: boolean;\n emitDeclarationOnly?: boolean;\n emitDecoratorMetadata?: boolean;\n isolatedModules?: boolean;\n allowJs?: boolean;\n outDir?: string;\n paths?: Record<string, string[]>;\n }\n | undefined;\n include?: string[];\n exclude?: string[];\n extends?: string;\n}\n"]}
|
package/dist/utils/builder.js
CHANGED
|
@@ -25,6 +25,26 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
25
|
mod
|
|
26
26
|
));
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var __async = (__this, __arguments, generator) => {
|
|
29
|
+
return new Promise((resolve, reject) => {
|
|
30
|
+
var fulfilled = (value) => {
|
|
31
|
+
try {
|
|
32
|
+
step(generator.next(value));
|
|
33
|
+
} catch (e) {
|
|
34
|
+
reject(e);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var rejected = (value) => {
|
|
38
|
+
try {
|
|
39
|
+
step(generator.throw(value));
|
|
40
|
+
} catch (e) {
|
|
41
|
+
reject(e);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
45
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
46
|
+
});
|
|
47
|
+
};
|
|
28
48
|
var builder_exports = {};
|
|
29
49
|
__export(builder_exports, {
|
|
30
50
|
getAllDeps: () => getAllDeps,
|
|
@@ -32,14 +52,15 @@ __export(builder_exports, {
|
|
|
32
52
|
});
|
|
33
53
|
module.exports = __toCommonJS(builder_exports);
|
|
34
54
|
var import_path = __toESM(require("path"));
|
|
35
|
-
|
|
55
|
+
var import_logger = require("@modern-js/utils/logger");
|
|
56
|
+
const getFinalExternals = (config, options) => __async(void 0, null, function* () {
|
|
36
57
|
const { autoExternal, externals } = config;
|
|
37
58
|
const { appDirectory } = options;
|
|
38
59
|
if (typeof autoExternal === "boolean") {
|
|
39
60
|
if (!autoExternal) {
|
|
40
61
|
return externals || [];
|
|
41
62
|
}
|
|
42
|
-
const deps2 =
|
|
63
|
+
const deps2 = yield getAllDeps(appDirectory, {
|
|
43
64
|
dependencies: true,
|
|
44
65
|
peerDependencies: true
|
|
45
66
|
});
|
|
@@ -48,14 +69,14 @@ const getFinalExternals = async (config, options) => {
|
|
|
48
69
|
...externals || []
|
|
49
70
|
];
|
|
50
71
|
}
|
|
51
|
-
const deps =
|
|
72
|
+
const deps = yield getAllDeps(appDirectory, autoExternal);
|
|
52
73
|
return [
|
|
53
74
|
...deps.map((dep) => new RegExp(`^${dep}($|\\/|\\\\)`)),
|
|
54
75
|
...externals || []
|
|
55
76
|
];
|
|
56
|
-
};
|
|
57
|
-
const getAllDeps =
|
|
58
|
-
const { fs } =
|
|
77
|
+
});
|
|
78
|
+
const getAllDeps = (_0, ..._1) => __async(void 0, [_0, ..._1], function* (appDirectory, options = {}) {
|
|
79
|
+
const { fs } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
59
80
|
try {
|
|
60
81
|
const json = JSON.parse(
|
|
61
82
|
fs.readFileSync(import_path.default.resolve(appDirectory, "./package.json"), "utf8")
|
|
@@ -75,10 +96,10 @@ const getAllDeps = async (appDirectory, options = {}) => {
|
|
|
75
96
|
}
|
|
76
97
|
return deps;
|
|
77
98
|
} catch (e) {
|
|
78
|
-
|
|
99
|
+
import_logger.logger.warn("package.json is broken");
|
|
79
100
|
return [];
|
|
80
101
|
}
|
|
81
|
-
};
|
|
102
|
+
});
|
|
82
103
|
// Annotate the CommonJS export names for ESM import in node:
|
|
83
104
|
0 && (module.exports = {
|
|
84
105
|
getAllDeps,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":"
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,oBAAuB;AAGhB,MAAM,oBAAoB,CAC/B,QACA,YACG;AACH,QAAM,EAAE,cAAc,UAAU,IAAI;AACpC,QAAM,EAAE,aAAa,IAAI;AAEzB,MAAI,OAAO,iBAAiB,WAAW;AACrC,QAAI,CAAC,cAAc;AACjB,aAAO,aAAa,CAAC;AAAA,IACvB;AAEA,UAAMA,QAAO,MAAM,WAAW,cAAc;AAAA,MAC1C,cAAc;AAAA,MACd,kBAAkB;AAAA,IACpB,CAAC;AACD,WAAO;AAAA,MACL,GAAGA,MAAK,IAAI,SAAO,IAAI,OAAO,IAAI,iBAAiB,CAAC;AAAA,MACpD,GAAI,aAAa,CAAC;AAAA,IACpB;AAAA,EACF;AAEA,QAAM,OAAO,MAAM,WAAW,cAAc,YAAY;AACxD,SAAO;AAAA,IACL,GAAG,KAAK,IAAI,SAAO,IAAI,OAAO,IAAI,iBAAiB,CAAC;AAAA,IACpD,GAAI,aAAa,CAAC;AAAA,EACpB;AACF;AAEO,MAAM,aAAa,CACxB,OAKG,wBALH,IAKG,mBALH,cACA,UAGI,CAAC,GACF;AACH,QAAM,EAAE,GAAG,IAAI,MAAM,6CAAO,kBAAkB;AAC9C,MAAI;AACF,UAAM,OAAO,KAAK;AAAA,MAChB,GAAG,aAAa,oBAAK,QAAQ,cAAc,gBAAgB,GAAG,MAAM;AAAA,IACtE;AAEA,QAAI,OAAiB,CAAC;AAEtB,QAAI,QAAQ,cAAc;AACxB,aAAO;AAAA,QACL,GAAG;AAAA,QACH,GAAG,OAAO,KAAM,KAAK,gBAAkC,CAAC,CAAC;AAAA,MAC3D;AAAA,IACF;AAEA,QAAI,QAAQ,kBAAkB;AAC5B,aAAO;AAAA,QACL,GAAG;AAAA,QACH,GAAG,OAAO,KAAM,KAAK,oBAAsC,CAAC,CAAC;AAAA,MAC/D;AAAA,IACF;AAEA,WAAO;AAAA,EACT,SAAS,GAAP;AACA,yBAAO,KAAK,wBAAwB;AACpC,WAAO,CAAC;AAAA,EACV;AACF;;;;;;","names":["deps"],"sources":["../../src/utils/builder.ts"],"sourcesContent":["import path from 'path';\nimport { logger } from '@modern-js/utils/logger';\nimport type { BaseBuildConfig } from '../types/config';\n\nexport const getFinalExternals = async (\n config: BaseBuildConfig,\n options: { appDirectory: string },\n) => {\n const { autoExternal, externals } = config;\n const { appDirectory } = options;\n\n if (typeof autoExternal === 'boolean') {\n if (!autoExternal) {\n return externals || [];\n }\n\n const deps = await getAllDeps(appDirectory, {\n dependencies: true,\n peerDependencies: true,\n });\n return [\n ...deps.map(dep => new RegExp(`^${dep}($|\\\\/|\\\\\\\\)`)),\n ...(externals || []),\n ];\n }\n\n const deps = await getAllDeps(appDirectory, autoExternal);\n return [\n ...deps.map(dep => new RegExp(`^${dep}($|\\\\/|\\\\\\\\)`)),\n ...(externals || []),\n ];\n};\n\nexport const getAllDeps = async <T>(\n appDirectory: string,\n options: {\n dependencies?: boolean;\n peerDependencies?: boolean;\n } = {},\n) => {\n const { fs } = await import('@modern-js/utils');\n try {\n const json = JSON.parse(\n fs.readFileSync(path.resolve(appDirectory, './package.json'), 'utf8'),\n );\n\n let deps: string[] = [];\n\n if (options.dependencies) {\n deps = [\n ...deps,\n ...Object.keys((json.dependencies as T | undefined) || {}),\n ];\n }\n\n if (options.peerDependencies) {\n deps = [\n ...deps,\n ...Object.keys((json.peerDependencies as T | undefined) || {}),\n ];\n }\n\n return deps;\n } catch (e) {\n logger.warn('package.json is broken');\n return [];\n }\n};\n"]}
|
package/dist/utils/common.js
CHANGED
|
@@ -1,7 +1,24 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
3
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
4
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
+
var __spreadValues = (a, b) => {
|
|
11
|
+
for (var prop in b || (b = {}))
|
|
12
|
+
if (__hasOwnProp.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
if (__getOwnPropSymbols)
|
|
15
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
+
if (__propIsEnum.call(b, prop))
|
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18
|
+
}
|
|
19
|
+
return a;
|
|
20
|
+
};
|
|
21
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
5
22
|
var __export = (target, all) => {
|
|
6
23
|
for (var name in all)
|
|
7
24
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -22,10 +39,9 @@ __export(common_exports, {
|
|
|
22
39
|
module.exports = __toCommonJS(common_exports);
|
|
23
40
|
const transformUndefineObject = (arr) => {
|
|
24
41
|
return arr.reduce((o, key) => {
|
|
25
|
-
return {
|
|
26
|
-
...o,
|
|
42
|
+
return __spreadProps(__spreadValues({}, o), {
|
|
27
43
|
[key]: void 0
|
|
28
|
-
};
|
|
44
|
+
});
|
|
29
45
|
}, {});
|
|
30
46
|
};
|
|
31
47
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/utils/common.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"mappings":"
|
|
1
|
+
{"version":3,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,0BAA0B,CACrC,QAC8B;AAC9B,SAAO,IAAI,OAAO,CAAC,GAAG,QAAQ;AAC5B,WAAO,iCACF,IADE;AAAA,MAEL,CAAC,GAAG,GAAG;AAAA,IACT;AAAA,EACF,GAAG,CAAC,CAAC;AACP;","names":[],"sources":["../../src/utils/common.ts"],"sourcesContent":["/**\n * transform ['a', 'b'] to {a: undefined, b: undefined}\n */\nexport const transformUndefineObject = (\n arr: string[],\n): Record<string, undefined> => {\n return arr.reduce((o, key) => {\n return {\n ...o,\n [key]: undefined,\n };\n }, {});\n};\n"]}
|