@modern-js/module-tools 2.10.1-beta.1 → 2.11.0

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.
Files changed (45) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/builder/build.js +7 -4
  3. package/dist/builder/build.js.map +1 -1
  4. package/dist/builder/copy.js +5 -4
  5. package/dist/builder/copy.js.map +1 -1
  6. package/dist/builder/dts/rollup.d.ts +4 -2
  7. package/dist/builder/dts/rollup.js +14 -10
  8. package/dist/builder/dts/rollup.js.map +1 -1
  9. package/dist/builder/dts/tsc.js +13 -12
  10. package/dist/builder/dts/tsc.js.map +1 -1
  11. package/dist/builder/index.js +3 -2
  12. package/dist/builder/index.js.map +1 -1
  13. package/dist/builder/platform.js +13 -12
  14. package/dist/builder/platform.js.map +1 -1
  15. package/dist/config/schema.d.ts +12 -0
  16. package/dist/config/schema.js +2 -1
  17. package/dist/config/schema.js.map +1 -1
  18. package/dist/constants/build.d.ts +0 -3
  19. package/dist/constants/build.js +2 -11
  20. package/dist/constants/build.js.map +1 -1
  21. package/dist/dev.js +3 -2
  22. package/dist/dev.js.map +1 -1
  23. package/dist/locale/en.d.ts +3 -0
  24. package/dist/locale/en.js +5 -3
  25. package/dist/locale/en.js.map +1 -1
  26. package/dist/locale/index.d.ts +6 -0
  27. package/dist/locale/zh.d.ts +3 -0
  28. package/dist/locale/zh.js +5 -3
  29. package/dist/locale/zh.js.map +1 -1
  30. package/dist/types/config/index.d.ts +1 -0
  31. package/dist/types/config/index.js.map +1 -1
  32. package/dist/types/dts.d.ts +1 -0
  33. package/dist/types/dts.js.map +1 -1
  34. package/dist/utils/builder.js +2 -1
  35. package/dist/utils/builder.js.map +1 -1
  36. package/dist/utils/dts.d.ts +6 -2
  37. package/dist/utils/dts.js +30 -2
  38. package/dist/utils/dts.js.map +1 -1
  39. package/dist/utils/libuildPlugins.js +2 -3
  40. package/dist/utils/libuildPlugins.js.map +1 -1
  41. package/dist/utils/log.js +3 -7
  42. package/dist/utils/log.js.map +1 -1
  43. package/dist/utils/print.js +7 -9
  44. package/dist/utils/print.js.map +1 -1
  45. package/package.json +13 -13
@@ -85,6 +85,9 @@ export declare const buildConfig: {
85
85
  tsconfigPath: {
86
86
  type: string;
87
87
  };
88
+ abortOnError: {
89
+ type: string;
90
+ };
88
91
  };
89
92
  };
90
93
  else: {
@@ -251,6 +254,9 @@ export declare const buildConfig: {
251
254
  tsconfigPath: {
252
255
  type: string;
253
256
  };
257
+ abortOnError: {
258
+ type: string;
259
+ };
254
260
  };
255
261
  };
256
262
  else: {
@@ -445,6 +451,9 @@ export declare const schema: ({
445
451
  tsconfigPath: {
446
452
  type: string;
447
453
  };
454
+ abortOnError: {
455
+ type: string;
456
+ };
448
457
  };
449
458
  };
450
459
  else: {
@@ -611,6 +620,9 @@ export declare const schema: ({
611
620
  tsconfigPath: {
612
621
  type: string;
613
622
  };
623
+ abortOnError: {
624
+ type: string;
625
+ };
614
626
  };
615
627
  };
616
628
  else: {
@@ -112,7 +112,8 @@ const buildConfigProperties = {
112
112
  then: {
113
113
  properties: {
114
114
  distPath: { type: "string" },
115
- tsconfigPath: { type: "string" }
115
+ tsconfigPath: { type: "string" },
116
+ abortOnError: { type: "boolean" }
116
117
  }
117
118
  },
118
119
  else: { type: "boolean" }
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgNA,0BAA6B;AAhNtB,MAAM,UAAU;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AACF;AAEO,MAAM,UAAU;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AAAA,IACD;AAAA,IACA;AAAA,IACA;AAAA,IACA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AAA,QACE,MAAM;AAAA,QACN,OAAO;AAAA,UACL,YAAY;AAAA,QACd;AAAA,MACF;AAAA,MACA;AAAA,QACE,MAAM;AAAA,MACR;AAAA,MACA;AAAA,QACE,YAAY;AAAA,MACd;AAAA,IACF;AAAA,EACF;AACF;AACO,MAAM,cAAc;AAAA,EACzB,QAAQ;AAAA,EACR,QAAQ;AAAA,IACN,IAAI;AAAA,MACF,MAAM;AAAA,IACR;AAAA,IACA,MAAM;AAAA,MACJ,OAAO;AAAA,QACL;AAAA,UACE,MAAM;AAAA,UACN,YAAY;AAAA,QACd;AAAA,MACF;AAAA,IACF;AAAA,IACA,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,YAAY;AAAA,IACd;AAAA,EACF;AACF;AACO,MAAM,cAAc;AAAA,EACzB,QAAQ;AAAA,EACR,QAAQ;AAAA,IACN,IAAI,EAAE,MAAM,SAAS;AAAA,IACrB,MAAM;AAAA,MACJ,MAAM;AAAA,IACR;AAAA,IACA,MAAM,EAAE,QAAQ,WAAW;AAAA,EAC7B;AACF;AAEO,MAAM,SAAS;AAAA,EACpB,QAAQ;AAAA,EACR,QAAQ;AAAA,IACN,MAAM;AAAA,EACR;AACF;AAEO,MAAM,SAAS,CAAC,aAAa,aAAa,MAAM;;;;;;;;;;;","names":[],"sources":["../../src/config/schema.ts"],"sourcesContent":["export const targets = [\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];\n\nexport const presets = [\n 'npm-library',\n 'npm-library-with-umd',\n 'npm-component',\n 'npm-component-with-umd',\n ...[\n 'npm-library',\n 'npm-library-with-umd',\n 'npm-component',\n 'npm-component-with-umd',\n ].reduce<string[]>((ret, crt) => {\n return [...ret, ...targets.map(t => `${crt}-${t}`)];\n }, []),\n 'modern-js-node',\n 'modern-js-universal',\n];\nconst buildConfigProperties = {\n alias: {\n typeof: ['object', 'function'],\n },\n asset: {\n type: 'object',\n },\n autoExternal: {\n if: {\n type: 'object',\n },\n then: {\n properties: {\n dependencies: { type: 'boolean' },\n peerDependencies: { type: 'boolean' },\n },\n },\n else: { type: 'boolean' },\n },\n buildType: {\n enum: ['bundle', 'bundleless'],\n },\n copy: {\n type: 'object',\n properties: {\n patterns: {\n type: 'array',\n items: {\n type: 'object',\n properties: {\n from: { type: 'string' },\n to: { type: 'string' },\n context: { type: 'string' },\n globOptions: { type: 'object' },\n },\n },\n },\n options: {\n type: 'object',\n properties: {\n concurrency: {\n type: 'number',\n },\n },\n },\n },\n },\n define: {\n typeof: 'object',\n },\n dts: {\n if: { type: 'object' },\n then: {\n properties: {\n distPath: { type: 'string' },\n tsconfigPath: { type: 'string' },\n },\n },\n else: { type: 'boolean' },\n },\n externals: {\n type: 'array',\n items: {\n anyOf: [\n {\n instanceof: 'RegExp',\n },\n {\n typeof: 'string',\n },\n ],\n },\n },\n format: {\n enum: ['cjs', 'esm', 'iife', 'umd'],\n },\n input: {\n type: ['array', 'object'],\n },\n jsx: {\n enum: ['automatic', 'transform'],\n },\n minify: {\n if: {\n type: 'object',\n },\n else: { enum: ['esbuild', 'terser', false] },\n },\n outDir: { type: 'string' },\n platform: {\n enum: ['node', 'browser'],\n },\n sourceDir: {\n typeof: 'string',\n },\n sourceMap: {\n enum: [true, false, 'inline', 'external'],\n },\n splitting: {\n type: 'boolean',\n },\n style: {\n // TODO: add properties\n type: 'object',\n },\n target: {\n enum: targets,\n },\n umdGlobals: {\n type: 'object',\n },\n umdModuleName: {\n anyOf: [\n {\n instanceof: 'Function',\n },\n {\n typeof: 'string',\n },\n ],\n },\n sideEffects: {\n anyOf: [\n {\n type: 'array',\n items: {\n instanceof: 'RegExp',\n },\n },\n {\n type: 'boolean',\n },\n {\n instanceof: 'Function',\n },\n ],\n },\n};\nexport const buildConfig = {\n target: 'buildConfig',\n schema: {\n if: {\n type: 'array',\n },\n then: {\n items: [\n {\n type: 'object',\n properties: buildConfigProperties,\n },\n ],\n },\n else: {\n type: 'object',\n properties: buildConfigProperties,\n },\n },\n};\nexport const buildPreset = {\n target: 'buildPreset',\n schema: {\n if: { type: 'string' },\n then: {\n enum: presets,\n },\n else: { typeof: 'function' },\n },\n};\n\nexport const legacy = {\n target: 'legacy',\n schema: {\n type: 'boolean',\n },\n};\n\nexport const schema = [buildConfig, buildPreset, legacy];\nexport { legacySchema } from './legacySchema';\n"]}
1
+ {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiNA,0BAA6B;AAjNtB,MAAM,UAAU;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AACF;AAEO,MAAM,UAAU;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AAAA,IACD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,EAAE,OAAiB,CAAC,KAAK,QAAQ;AAC/B,WAAO,CAAC,GAAG,KAAK,GAAG,QAAQ,IAAI,OAAK,GAAG,OAAO,GAAG,CAAC;AAAA,EACpD,GAAG,CAAC,CAAC;AAAA,EACL;AAAA,EACA;AACF;AACA,MAAM,wBAAwB;AAAA,EAC5B,OAAO;AAAA,IACL,QAAQ,CAAC,UAAU,UAAU;AAAA,EAC/B;AAAA,EACA,OAAO;AAAA,IACL,MAAM;AAAA,EACR;AAAA,EACA,cAAc;AAAA,IACZ,IAAI;AAAA,MACF,MAAM;AAAA,IACR;AAAA,IACA,MAAM;AAAA,MACJ,YAAY;AAAA,QACV,cAAc,EAAE,MAAM,UAAU;AAAA,QAChC,kBAAkB,EAAE,MAAM,UAAU;AAAA,MACtC;AAAA,IACF;AAAA,IACA,MAAM,EAAE,MA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Q;AAAA,EACR,QAAQ;AAAA,IACN,IAAI,EAAE,MAAM,SAAS;AAAA,IACrB,MAAM;AAAA,MACJ,MAAM;AAAA,IACR;AAAA,IACA,MAAM,EAAE,QAAQ,WAAW;AAAA,EAC7B;AACF;AAEO,MAAM,SAAS;AAAA,EACpB,QAAQ;AAAA,EACR,QAAQ;AAAA,IACN,MAAM;AAAA,EACR;AACF;AAEO,MAAM,SAAS,CAAC,aAAa,aAAa,MAAM;;;;;;;;;;;","names":[],"sources":["../../src/config/schema.ts"],"sourcesContent":["export const targets = [\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];\n\nexport const presets = [\n 'npm-library',\n 'npm-library-with-umd',\n 'npm-component',\n 'npm-component-with-umd',\n ...[\n 'npm-library',\n 'npm-library-with-umd',\n 'npm-component',\n 'npm-component-with-umd',\n ].reduce<string[]>((ret, crt) => {\n return [...ret, ...targets.map(t => `${crt}-${t}`)];\n }, []),\n 'modern-js-node',\n 'modern-js-universal',\n];\nconst buildConfigProperties = {\n alias: {\n typeof: ['object', 'function'],\n },\n asset: {\n type: 'object',\n },\n autoExternal: {\n if: {\n type: 'object',\n },\n then: {\n properties: {\n dependencies: { type: 'boolean' },\n peerDependencies: { type: 'boolean' },\n },\n },\n else: { type: 'boolean' },\n },\n buildType: {\n enum: ['bundle', 'bundleless'],\n },\n copy: {\n type: 'object',\n properties: {\n patterns: {\n type: 'array',\n items: {\n type: 'object',\n properties: {\n from: { type: 'string' },\n to: { type: 'string' },\n context: { type: 'string' },\n globOptions: { type: 'object' },\n },\n },\n },\n options: {\n type: 'object',\n properties: {\n concurrency: {\n type: 'number',\n },\n },\n },\n },\n },\n define: {\n typeof: 'object',\n },\n dts: {\n if: { type: 'object' },\n then: {\n properties: {\n distPath: { type: 'string' },\n tsconfigPath: { type: 'string' },\n abortOnError: { type: 'boolean' },\n },\n },\n else: { type: 'boolean' },\n },\n externals: {\n type: 'array',\n items: {\n anyOf: [\n {\n instanceof: 'RegExp',\n },\n {\n typeof: 'string',\n },\n ],\n },\n },\n format: {\n enum: ['cjs', 'esm', 'iife', 'umd'],\n },\n input: {\n type: ['array', 'object'],\n },\n jsx: {\n enum: ['automatic', 'transform'],\n },\n minify: {\n if: {\n type: 'object',\n },\n else: { enum: ['esbuild', 'terser', false] },\n },\n outDir: { type: 'string' },\n platform: {\n enum: ['node', 'browser'],\n },\n sourceDir: {\n typeof: 'string',\n },\n sourceMap: {\n enum: [true, false, 'inline', 'external'],\n },\n splitting: {\n type: 'boolean',\n },\n style: {\n // TODO: add properties\n type: 'object',\n },\n target: {\n enum: targets,\n },\n umdGlobals: {\n type: 'object',\n },\n umdModuleName: {\n anyOf: [\n {\n instanceof: 'Function',\n },\n {\n typeof: 'string',\n },\n ],\n },\n sideEffects: {\n anyOf: [\n {\n type: 'array',\n items: {\n instanceof: 'RegExp',\n },\n },\n {\n type: 'boolean',\n },\n {\n instanceof: 'Function',\n },\n ],\n },\n};\nexport const buildConfig = {\n target: 'buildConfig',\n schema: {\n if: {\n type: 'array',\n },\n then: {\n items: [\n {\n type: 'object',\n properties: buildConfigProperties,\n },\n ],\n },\n else: {\n type: 'object',\n properties: buildConfigProperties,\n },\n },\n};\nexport const buildPreset = {\n target: 'buildPreset',\n schema: {\n if: { type: 'string' },\n then: {\n enum: presets,\n },\n else: { typeof: 'function' },\n },\n};\n\nexport const legacy = {\n target: 'legacy',\n schema: {\n type: 'boolean',\n },\n};\n\nexport const schema = [buildConfig, buildPreset, legacy];\nexport { legacySchema } from './legacySchema';\n"]}
@@ -1,5 +1,2 @@
1
1
  import type { BaseBuildConfig } from '../types';
2
- export declare const buildingText: string;
3
- export declare const buildSuccessText: string;
4
- export declare const buildFailText: string;
5
2
  export declare const defaultBuildConfig: Readonly<BaseBuildConfig>;
@@ -17,16 +17,9 @@ var __copyProps = (to, from, except, desc) => {
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
18
  var build_exports = {};
19
19
  __export(build_exports, {
20
- buildFailText: () => buildFailText,
21
- buildSuccessText: () => buildSuccessText,
22
- buildingText: () => buildingText,
23
20
  defaultBuildConfig: () => defaultBuildConfig
24
21
  });
25
22
  module.exports = __toCommonJS(build_exports);
26
- var import_utils = require("@modern-js/utils");
27
- const buildingText = import_utils.chalk.blue("Building...");
28
- const buildSuccessText = import_utils.chalk.green("Build succeed");
29
- const buildFailText = import_utils.chalk.red("Build Failed:");
30
23
  const defaultBuildConfig = Object.freeze({
31
24
  buildType: "bundle",
32
25
  format: "cjs",
@@ -37,7 +30,8 @@ const defaultBuildConfig = Object.freeze({
37
30
  dts: Object.freeze({
38
31
  only: false,
39
32
  distPath: "./",
40
- tsconfigPath: "./tsconfig.json"
33
+ tsconfigPath: "./tsconfig.json",
34
+ abortOnError: true
41
35
  }),
42
36
  jsx: "automatic",
43
37
  input: ["src/index.ts"],
@@ -71,9 +65,6 @@ const defaultBuildConfig = Object.freeze({
71
65
  });
72
66
  // Annotate the CommonJS export names for ESM import in node:
73
67
  0 && (module.exports = {
74
- buildFailText,
75
- buildSuccessText,
76
- buildingText,
77
68
  defaultBuildConfig
78
69
  });
79
70
 
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAsB;AAGf,MAAM,eAAe,mBAAM,KAAK,aAAa;AAC7C,MAAM,mBAAmB,mBAAM,MAAM,eAAe;AACpD,MAAM,gBAAgB,mBAAM,IAAI,eAAe;AAE/C,MAAM,qBAAqB,OAAO,OAAwB;AAAA,EAC/D,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,MAAM,CAAC;AAAA,EACP,QAAQ;AAAA,EACR,KAAK,OAAO,OAAO;AAAA,IACjB,MAAM;AAAA,IACN,UAAU;AAAA,IACV,cAAc;AAAA,EAChB,CAAC;AAAA,EACD,KAAK;AAAA,EACL,OAAO,CAAC,cAAc;AAAA,EACtB,UAAU;AAAA,EACV,WAAW;AAAA,EACX,WAAW,CAAC;AAAA,EACZ,QAAQ;AAAA,EACR,cAAc;AAAA,EACd,YAAY,CAAC;AAAA,EACb,WAAW;AAAA,EACX,OAAO,CAAC;AAAA,EACR,UAAU;AAAA,EACV,eAAe,UAAQ;AAAA,EACvB,QAAQ,CAAC;AAAA,EACT,OAAO;AAAA,IACL,MAAM;AAAA,IACN,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,MAAM;AAAA,EACR;AAAA,EACA,OAAO;AAAA,IACL,MAAM,CAAC;AAAA,IACP,MAAM,CAAC;AAAA,IACP,SAAS,CAAC;AAAA,IACV,aAAa,CAAC;AAAA,IACd,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,SAAS,CAAC;AAAA,EACZ;AAAA,EACA,aAAa;AACf,CAAC;;;;;;;;","names":[],"sources":["../../src/constants/build.ts"],"sourcesContent":["import { chalk } from '@modern-js/utils';\nimport type { BaseBuildConfig } from '../types';\n\nexport const buildingText = chalk.blue('Building...');\nexport const buildSuccessText = chalk.green('Build succeed');\nexport const buildFailText = chalk.red('Build Failed:');\n\nexport const defaultBuildConfig = Object.freeze<BaseBuildConfig>({\n buildType: 'bundle',\n format: 'cjs',\n target: 'es6',\n sourceMap: false,\n copy: {},\n outDir: './dist',\n dts: Object.freeze({\n only: false,\n distPath: './',\n tsconfigPath: './tsconfig.json',\n }),\n jsx: 'automatic',\n input: ['src/index.ts'],\n platform: 'node',\n splitting: false,\n externals: [],\n minify: false,\n autoExternal: true,\n umdGlobals: {},\n sourceDir: './src',\n alias: {},\n metafile: false,\n umdModuleName: name => name,\n define: {},\n asset: {\n path: 'assets',\n limit: 14336,\n publicPath: '',\n svgr: false,\n },\n style: {\n less: {},\n sass: {},\n postcss: {},\n tailwindCss: {},\n inject: false,\n autoModules: true,\n modules: {},\n },\n sideEffects: undefined,\n});\n"]}
1
+ {"version":3,"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,MAAM,qBAAqB,OAAO,OAAwB;AAAA,EAC/D,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,MAAM,CAAC;AAAA,EACP,QAAQ;AAAA,EACR,KAAK,OAAO,OAAO;AAAA,IACjB,MAAM;AAAA,IACN,UAAU;AAAA,IACV,cAAc;AAAA,IACd,cAAc;AAAA,EAChB,CAAC;AAAA,EACD,KAAK;AAAA,EACL,OAAO,CAAC,cAAc;AAAA,EACtB,UAAU;AAAA,EACV,WAAW;AAAA,EACX,WAAW,CAAC;AAAA,EACZ,QAAQ;AAAA,EACR,cAAc;AAAA,EACd,YAAY,CAAC;AAAA,EACb,WAAW;AAAA,EACX,OAAO,CAAC;AAAA,EACR,UAAU;AAAA,EACV,eAAe,UAAQ;AAAA,EACvB,QAAQ,CAAC;AAAA,EACT,OAAO;AAAA,IACL,MAAM;AAAA,IACN,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,MAAM;AAAA,EACR;AAAA,EACA,OAAO;AAAA,IACL,MAAM,CAAC;AAAA,IACP,MAAM,CAAC;AAAA,IACP,SAAS,CAAC;AAAA,IACV,aAAa,CAAC;AAAA,IACd,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,SAAS,CAAC;AAAA,EACZ;AAAA,EACA,aAAa;AACf,CAAC;","names":[],"sources":["../../src/constants/build.ts"],"sourcesContent":["import type { BaseBuildConfig } from '../types';\n\nexport const defaultBuildConfig = Object.freeze<BaseBuildConfig>({\n buildType: 'bundle',\n format: 'cjs',\n target: 'es6',\n sourceMap: false,\n copy: {},\n outDir: './dist',\n dts: Object.freeze({\n only: false,\n distPath: './',\n tsconfigPath: './tsconfig.json',\n abortOnError: true,\n }),\n jsx: 'automatic',\n input: ['src/index.ts'],\n platform: 'node',\n splitting: false,\n externals: [],\n minify: false,\n autoExternal: true,\n umdGlobals: {},\n sourceDir: './src',\n alias: {},\n metafile: false,\n umdModuleName: name => name,\n define: {},\n asset: {\n path: 'assets',\n limit: 14336,\n publicPath: '',\n svgr: false,\n },\n style: {\n less: {},\n sass: {},\n postcss: {},\n tailwindCss: {},\n inject: false,\n autoModules: true,\n modules: {},\n },\n sideEffects: undefined,\n});\n"]}
package/dist/dev.js CHANGED
@@ -51,6 +51,7 @@ __export(dev_exports, {
51
51
  showMenu: () => showMenu
52
52
  });
53
53
  module.exports = __toCommonJS(dev_exports);
54
+ var import_logger = require("@modern-js/utils/logger");
54
55
  const showMenu = (metas, devCmdOptions, api, context) => __async(void 0, null, function* () {
55
56
  const { chalk, inquirer } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
56
57
  const runner = api.useHookRunners();
@@ -92,11 +93,11 @@ const dev = (options, metas, api, context) => __async(void 0, null, function* ()
92
93
  const noDevToolsLog = yield runner.noDevTools(
93
94
  local.i18n.t(local.localeKeys.log.dev.noDevtools)
94
95
  );
95
- console.info(noDevToolsLog);
96
+ import_logger.logger.info(noDevToolsLog);
96
97
  process.exit(0);
97
98
  }
98
99
  if (metas.length === 1) {
99
- console.info(
100
+ import_logger.logger.info(
100
101
  chalk.rgb(...green)(
101
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}]`
102
103
  )
package/dist/dev.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAwCO,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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B,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 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 console.info(noDevToolsLog);\n // eslint-disable-next-line no-process-exit\n process.exit(0);\n }\n\n if (metas.length === 1) {\n console.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"]}
1
+ {"version":3,"file":null,"mappings":";;;;;;;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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"]}
@@ -29,4 +29,7 @@ export declare const EN_LOCALE: {
29
29
  noDevtools: string;
30
30
  };
31
31
  };
32
+ dts: {
33
+ abortOnError: string;
34
+ };
32
35
  };
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
- There are no DevTools available, you can learn about them and choose to use them by following the link options.
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:
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAsB;AAEtB,MAAM,aAAa;AAAA;AAAA,IAEf,mBAAM;AAAA,EACR,mBAAM,KAAK,aAAa;AAAA,EACxB;AACF;AAAA;AAGO,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;AACF;;;;;","names":[],"sources":["../../src/locale/en.ts"],"sourcesContent":["import { chalk } from '@modern-js/utils';\n\nconst noDevTools = `\nThere 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};\n"]}
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"]}
@@ -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 };
@@ -29,4 +29,7 @@ export declare const ZH_LOCALE: {
29
29
  noDevtools: string;
30
30
  };
31
31
  };
32
+ dts: {
33
+ abortOnError: string;
34
+ };
32
35
  };
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
- 暂无可用的 DevTools,可以通过以下选项以及对应的链接了解如何使用。
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:
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAsB;AAEtB,MAAM,aAAa;AAAA;AAAA,IAEf,mBAAM;AAAA,EACR,mBAAM,KAAK,cAAc;AAAA,EACzB;AACF;AAAA;AAGO,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;AACF;;;;;","names":[],"sources":["../../src/locale/zh.ts"],"sourcesContent":["import { chalk } from '@modern-js/utils';\n\nconst noDevTools = `\n暂无可用的 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};\n"]}
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"]}
@@ -6,6 +6,7 @@ export interface BundlelessGeneratorDtsConfig {
6
6
  watch: boolean;
7
7
  sourceDir: string;
8
8
  alias: AliasOption;
9
+ abortOnError?: boolean;
9
10
  }
10
11
  export interface ITsconfig {
11
12
  compilerOptions?: {
@@ -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"]}
@@ -52,6 +52,7 @@ __export(builder_exports, {
52
52
  });
53
53
  module.exports = __toCommonJS(builder_exports);
54
54
  var import_path = __toESM(require("path"));
55
+ var import_logger = require("@modern-js/utils/logger");
55
56
  const getFinalExternals = (config, options) => __async(void 0, null, function* () {
56
57
  const { autoExternal, externals } = config;
57
58
  const { appDirectory } = options;
@@ -95,7 +96,7 @@ const getAllDeps = (_0, ..._1) => __async(void 0, [_0, ..._1], function* (appDir
95
96
  }
96
97
  return deps;
97
98
  } catch (e) {
98
- console.warn("[WARN] package.json is broken");
99
+ import_logger.logger.warn("package.json is broken");
99
100
  return [];
100
101
  }
101
102
  });
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAGV,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,YAAQ,KAAK,+BAA+B;AAC5C,WAAO,CAAC;AAAA,EACV;AACF;;;;;;","names":["deps"],"sources":["../../src/utils/builder.ts"],"sourcesContent":["import path from 'path';\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 console.warn('[WARN] package.json is broken');\n return [];\n }\n};\n"]}
1
+ {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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AAA,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"]}
@@ -1,4 +1,4 @@
1
- import type { ITsconfig, BundlelessGeneratorDtsConfig, BuildCommandOptions, BaseBuildConfig } from '../types';
1
+ import type { ITsconfig, BundlelessGeneratorDtsConfig, BuildCommandOptions, BaseBuildConfig, BuildType } from '../types';
2
2
  export declare const generatorTsConfig: (config: BundlelessGeneratorDtsConfig) => Promise<{
3
3
  tempTsconfigPath: string;
4
4
  tempDistAbsRootPath: string;
@@ -11,4 +11,8 @@ export declare const resolveAlias: (config: BundlelessGeneratorDtsConfig, option
11
11
  tempDistAbsRootPath: string;
12
12
  tempDistAbsSrcPath: string;
13
13
  }, watchFilenames?: string[]) => Promise<void>;
14
- export declare const assignTsConfigPath: (config: BaseBuildConfig, options: BuildCommandOptions) => Promise<BaseBuildConfig>;
14
+ export declare const assignTsConfigPath: (config: BaseBuildConfig, options: BuildCommandOptions) => Promise<BaseBuildConfig>;
15
+ export declare const printOrThrowDtsErrors: (error: unknown, options: {
16
+ abortOnError?: boolean;
17
+ buildType: BuildType;
18
+ }) => Promise<void>;
package/dist/utils/dts.js CHANGED
@@ -67,6 +67,7 @@ __export(dts_exports, {
67
67
  assignTsConfigPath: () => assignTsConfigPath,
68
68
  generatorTsConfig: () => generatorTsConfig,
69
69
  getTscBinPath: () => getTscBinPath,
70
+ printOrThrowDtsErrors: () => printOrThrowDtsErrors,
70
71
  resolveAlias: () => resolveAlias
71
72
  });
72
73
  module.exports = __toCommonJS(dts_exports);
@@ -83,7 +84,10 @@ const generatorTsConfig = (config) => __async(void 0, null, function* () {
83
84
  tempDistAbsRootPath,
84
85
  import_path.default.relative(appDirectory, absSourceDir)
85
86
  );
86
- const tempTsconfigPath = import_path.default.join(tempDistAbsRootPath, `tsconfig.json`);
87
+ const tempTsconfigPath = import_path.default.join(
88
+ tempDistAbsRootPath,
89
+ import_path.default.basename(tsconfigPath)
90
+ );
87
91
  fs.ensureFileSync(tempTsconfigPath);
88
92
  const extendsPath = import_path.default.join(
89
93
  import_path.default.relative(import_path.default.dirname(tempTsconfigPath), import_path.default.dirname(tsconfigPath)),
@@ -150,18 +154,42 @@ const assignTsConfigPath = (config, options) => __async(void 0, null, function*
150
154
  if (typeof options.tsconfig === "string" && options.tsconfig !== defaultTsConfigPath) {
151
155
  config.dts = __spreadProps(__spreadValues({
152
156
  only: false,
153
- distPath: "./"
157
+ distPath: "./",
158
+ abortOnError: true
154
159
  }, (_a = config.dts) != null ? _a : {}), {
155
160
  tsconfigPath: options.tsconfig
156
161
  });
157
162
  }
158
163
  return config;
159
164
  });
165
+ const printOrThrowDtsErrors = (error, options) => __async(void 0, null, function* () {
166
+ const { logger, chalk } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
167
+ const { InternalDTSError } = yield Promise.resolve().then(() => __toESM(require("../error")));
168
+ const local = yield Promise.resolve().then(() => __toESM(require("../locale")));
169
+ const { abortOnError, buildType } = options != null ? options : {};
170
+ if (error instanceof Error) {
171
+ if (abortOnError) {
172
+ throw new InternalDTSError(error, {
173
+ buildType
174
+ });
175
+ } else {
176
+ logger.warn(
177
+ chalk.bgYellowBright(local.i18n.t(local.localeKeys.dts.abortOnError))
178
+ );
179
+ logger.error(
180
+ new InternalDTSError(error, {
181
+ buildType
182
+ })
183
+ );
184
+ }
185
+ }
186
+ });
160
187
  // Annotate the CommonJS export names for ESM import in node:
161
188
  0 && (module.exports = {
162
189
  assignTsConfigPath,
163
190
  generatorTsConfig,
164
191
  getTscBinPath,
192
+ printOrThrowDtsErrors,
165
193
  resolveAlias
166
194
  });
167
195
 
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAYV,MAAM,oBAAoB,CAC/B,WACG;AACH,QAAM,EAAE,IAAI,OAAO,IAAI,MAAM,6CAAO,kBAAkB;AACtD,QAAM,EAAE,iBAAiB,IAAI,MAAM,6CAAO,kBAAkB;AAE5D,QAAM,EAAE,cAAc,WAAW,cAAc,aAAa,IAAI;AAChE,QAAM,sBAAsB,oBAAK;AAAA,IAC/B;AAAA,IACA,GAAG,oBAAoB,OAAO;AAAA,EAChC;AACA,QAAM,oBAAoB,oBAAK;AAAA,IAC7B;AAAA,IACA,oBAAK,SAAS,cAAc,YAAY;AAAA,EAC1C;AAEA,QAAM,mBAAmB,oBAAK,KAAK,qBAAqB,eAAe;AACvE,KAAG,e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,cAAc,GAAG;AACvB,QAAM,eACJ,eAAe,SAAS,IACpB,iBACA,OAAO,KAAK,aAAa,EAAE,UAAU,KAAK,CAAC;AACjD,QAAM,SAAS,kBAAkB;AAAA,IAC/B,WAAW;AAAA,IACX,SAAS;AAAA,IACT,QAAO,wBAAa,oBAAb,mBAA8B,UAA9B,YAAuC,CAAC;AAAA,EACjD,CAAC;AACD,aAAW,KAAK,QAAQ;AACtB,OAAG,cAAc,EAAE,MAAM,EAAE,OAAO;AAAA,EACpC;AAEA,QAAM,GAAG,KAAK,oBAAoB,WAAW;AAC/C;AAgDO,MAAM,qBAAqB,CAChC,QACA,YACG;AAjKL;AAkKE,QAAM,EAAE,oBAAoB,IAAI,MAAM,6CAAO,kBAAkB;AAG/D,MACE,OAAO,QAAQ,aAAa,YAC5B,QAAQ,aAAa,qBACrB;AACA,WAAO,MAAM;AAAA,MACX,MAAM;AAAA,MACN,UAAU;AAAA,QACN,YAAO,QAAP,YAAc,CAAC,IAHR;AAAA,MAIX,cAAc,QAAQ;AAAA,IACxB;AAAA,EACF;AAEA,SAAO;AACT;;;;;;;;","names":[],"sources":["../../src/utils/dts.ts"],"sourcesContent":["import path from 'path';\n// import type { NodePath } from '../../compiled/@babel/traverse';\n// import type * as tt from '../../compiled/@babel/types';\n// import t from '../../compiled/@babel/types';\nimport type {\n ITsconfig,\n BundlelessGeneratorDtsConfig,\n BuildCommandOptions,\n BaseBuildConfig,\n // AliasOption,\n} from '../types';\n\nexport const generatorTsConfig = async (\n config: BundlelessGeneratorDtsConfig,\n) => {\n const { fs, nanoid } = await import('@modern-js/utils');\n const { dtsTempDirectory } = await import('../constants/dts');\n\n const { appDirectory, sourceDir: absSourceDir, tsconfigPath } = config;\n const tempDistAbsRootPath = path.join(\n appDirectory,\n `${dtsTempDirectory}/${nanoid()}`,\n );\n const tempDistAbsOurDir = path.join(\n tempDistAbsRootPath,\n path.relative(appDirectory, absSourceDir),\n );\n\n const tempTsconfigPath = path.join(tempDistAbsRootPath, `tsconfig.json`);\n fs.ensureFileSync(tempTsconfigPath);\n\n const extendsPath = path.join(\n path.relative(path.dirname(tempTsconfigPath), path.dirname(tsconfigPath)),\n path.basename(tempTsconfigPath),\n );\n\n const resetConfig: ITsconfig = {\n extends: extendsPath,\n compilerOptions: {\n // Ensure that .d.ts files are created by tsc, but not .js files\n declaration: true,\n emitDeclarationOnly: true,\n outDir: tempDistAbsOurDir,\n },\n };\n\n fs.writeJSONSync(tempTsconfigPath, resetConfig);\n\n return {\n tempTsconfigPath,\n tempDistAbsRootPath,\n tempDistAbsSrcPath: tempDistAbsOurDir,\n };\n};\n\nexport const getTscBinPath = async (appDirectory: string) => {\n const { fs } = await import('@modern-js/utils');\n const { default: findUp, exists: pathExists } = await import(\n '../../compiled/find-up'\n );\n const tscBinFile = await findUp(\n async (directory: string) => {\n const targetFilePath = path.join(directory, './node_modules/.bin/tsc');\n const hasTscBinFile = await pathExists(targetFilePath);\n if (hasTscBinFile) {\n return targetFilePath;\n }\n return undefined;\n },\n { cwd: appDirectory },\n );\n\n if (!tscBinFile || !fs.existsSync(tscBinFile)) {\n throw new Error(\n 'Failed to excute the `tsc` command, please check if `typescript` is installed correctly in the current directory.',\n );\n }\n\n return tscBinFile;\n};\n\nexport const resolveAlias = async (\n config: BundlelessGeneratorDtsConfig,\n options: {\n userTsconfig: ITsconfig;\n tempTsconfigPath: string;\n tempDistAbsRootPath: string;\n tempDistAbsSrcPath: string;\n },\n watchFilenames: string[] = [],\n) => {\n const { userTsconfig, tempDistAbsSrcPath, tempDistAbsRootPath } = options;\n const { globby, fs } = await import('@modern-js/utils');\n const { transformDtsAlias } = await import('./tspathsTransform');\n const { distAbsPath } = config;\n const dtsDistPath = `${tempDistAbsSrcPath}/**/*.d.ts`;\n const dtsFilenames =\n watchFilenames.length > 0\n ? watchFilenames\n : globby.sync(dtsDistPath, { absolute: true });\n const result = transformDtsAlias({\n filenames: dtsFilenames,\n baseUrl: tempDistAbsRootPath,\n paths: userTsconfig.compilerOptions?.paths ?? {},\n });\n for (const r of result) {\n fs.writeFileSync(r.path, r.content);\n }\n\n await fs.copy(tempDistAbsSrcPath, distAbsPath);\n};\n\n// export const matchesPattern = (calleePath: NodePath, pattern: string) => {\n// const { node } = calleePath;\n\n// if (t.isMemberExpression(node)) {\n// return calleePath.matchesPattern(pattern);\n// }\n\n// if (!t.isIdentifier(node) || pattern.includes('.')) {\n// return false;\n// }\n\n// const name = pattern.split('.')[0];\n\n// return node.name === name;\n// };\n\n// export const isImportCall = (calleePath: NodePath<tt.CallExpression>) => {\n// return t.isImport(calleePath.node.callee);\n// };\n\n// export const verifyTsConfigPaths = async (\n// tsconfigAbsPath: string,\n// userAliases?: AliasOption,\n// ) => {\n// const { readTsConfigByFile, chalk } = await import('@modern-js/utils');\n// if (!userAliases) {\n// return;\n// }\n\n// const paths = Object.keys(\n// readTsConfigByFile(tsconfigAbsPath).compilerOptions?.paths || {},\n// ).map(key => key.replace(/\\/\\*$/, ''));\n\n// Object.keys(userAliases).forEach(name => {\n// if (paths.includes(name)) {\n// throw new Error(\n// chalk.red(\n// `It looks like you have configured the alias ${chalk.bold(\n// name,\n// )} in both the modern.config file and tsconfig.json.\\n Please remove the configuration in modern.config file and just keep the configuration in tsconfig.json.`,\n// ),\n// );\n// }\n// });\n// };\n\nexport const assignTsConfigPath = async (\n config: BaseBuildConfig,\n options: BuildCommandOptions,\n) => {\n const { defaultTsConfigPath } = await import('../constants/dts');\n\n // user run `build --tsconfig './tsconfig.build.json'`\n if (\n typeof options.tsconfig === 'string' &&\n options.tsconfig !== defaultTsConfigPath\n ) {\n config.dts = {\n only: false,\n distPath: './',\n ...(config.dts ?? {}),\n tsconfigPath: options.tsconfig,\n };\n }\n\n return config;\n};\n"]}
1
+ {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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AM,IAAI,MAAM,6CAAO,kBAAkB;AACzD,QAAM,EAAE,iBAAiB,IAAI,MAAM,6CAAO,UAAU;AACpD,QAAM,QAAQ,MAAM,6CAAO,WAAW;AACtC,QAAM,EAAE,cAAc,UAAU,IAAI,4BAAW,CAAC;AAChD,MAAI,iBAAiB,OAAO;AAC1B,QAAI,cAAc;AAChB,YAAM,IAAI,iBAAiB,OAAO;AAAA,QAChC;AAAA,MACF,CAAC;AAAA,IACH,OAAO;AACL,aAAO;AAAA,QACL,MAAM,eAAe,MAAM,KAAK,EAAE,MAAM,WAAW,IAAI,YAAY,CAAC;AAAA,MACtE;AACA,aAAO;AAAA,QACL,IAAI,iBAAiB,OAAO;AAAA,UAC1B;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACF;;;;;;;;;","names":[],"sources":["../../src/utils/dts.ts"],"sourcesContent":["import path from 'path';\n// import type { NodePath } from '../../compiled/@babel/traverse';\n// import type * as tt from '../../compiled/@babel/types';\n// import t from '../../compiled/@babel/types';\nimport type {\n ITsconfig,\n BundlelessGeneratorDtsConfig,\n BuildCommandOptions,\n BaseBuildConfig,\n BuildType,\n // AliasOption,\n} from '../types';\n\nexport const generatorTsConfig = async (\n config: BundlelessGeneratorDtsConfig,\n) => {\n const { fs, nanoid } = await import('@modern-js/utils');\n const { dtsTempDirectory } = await import('../constants/dts');\n\n const { appDirectory, sourceDir: absSourceDir, tsconfigPath } = config;\n const tempDistAbsRootPath = path.join(\n appDirectory,\n `${dtsTempDirectory}/${nanoid()}`,\n );\n const tempDistAbsOurDir = path.join(\n tempDistAbsRootPath,\n path.relative(appDirectory, absSourceDir),\n );\n\n const tempTsconfigPath = path.join(\n tempDistAbsRootPath,\n path.basename(tsconfigPath),\n );\n fs.ensureFileSync(tempTsconfigPath);\n\n const extendsPath = path.join(\n path.relative(path.dirname(tempTsconfigPath), path.dirname(tsconfigPath)),\n path.basename(tempTsconfigPath),\n );\n\n const resetConfig: ITsconfig = {\n extends: extendsPath,\n compilerOptions: {\n // Ensure that .d.ts files are created by tsc, but not .js files\n declaration: true,\n emitDeclarationOnly: true,\n outDir: tempDistAbsOurDir,\n },\n };\n\n fs.writeJSONSync(tempTsconfigPath, resetConfig);\n\n return {\n tempTsconfigPath,\n tempDistAbsRootPath,\n tempDistAbsSrcPath: tempDistAbsOurDir,\n };\n};\n\nexport const getTscBinPath = async (appDirectory: string) => {\n const { fs } = await import('@modern-js/utils');\n const { default: findUp, exists: pathExists } = await import(\n '../../compiled/find-up'\n );\n const tscBinFile = await findUp(\n async (directory: string) => {\n const targetFilePath = path.join(directory, './node_modules/.bin/tsc');\n const hasTscBinFile = await pathExists(targetFilePath);\n if (hasTscBinFile) {\n return targetFilePath;\n }\n return undefined;\n },\n { cwd: appDirectory },\n );\n\n if (!tscBinFile || !fs.existsSync(tscBinFile)) {\n throw new Error(\n 'Failed to excute the `tsc` command, please check if `typescript` is installed correctly in the current directory.',\n );\n }\n\n return tscBinFile;\n};\n\nexport const resolveAlias = async (\n config: BundlelessGeneratorDtsConfig,\n options: {\n userTsconfig: ITsconfig;\n tempTsconfigPath: string;\n tempDistAbsRootPath: string;\n tempDistAbsSrcPath: string;\n },\n watchFilenames: string[] = [],\n) => {\n const { userTsconfig, tempDistAbsSrcPath, tempDistAbsRootPath } = options;\n const { globby, fs } = await import('@modern-js/utils');\n const { transformDtsAlias } = await import('./tspathsTransform');\n const { distAbsPath } = config;\n const dtsDistPath = `${tempDistAbsSrcPath}/**/*.d.ts`;\n const dtsFilenames =\n watchFilenames.length > 0\n ? watchFilenames\n : globby.sync(dtsDistPath, { absolute: true });\n const result = transformDtsAlias({\n filenames: dtsFilenames,\n baseUrl: tempDistAbsRootPath,\n paths: userTsconfig.compilerOptions?.paths ?? {},\n });\n for (const r of result) {\n fs.writeFileSync(r.path, r.content);\n }\n\n await fs.copy(tempDistAbsSrcPath, distAbsPath);\n};\n\n// export const matchesPattern = (calleePath: NodePath, pattern: string) => {\n// const { node } = calleePath;\n\n// if (t.isMemberExpression(node)) {\n// return calleePath.matchesPattern(pattern);\n// }\n\n// if (!t.isIdentifier(node) || pattern.includes('.')) {\n// return false;\n// }\n\n// const name = pattern.split('.')[0];\n\n// return node.name === name;\n// };\n\n// export const isImportCall = (calleePath: NodePath<tt.CallExpression>) => {\n// return t.isImport(calleePath.node.callee);\n// };\n\n// export const verifyTsConfigPaths = async (\n// tsconfigAbsPath: string,\n// userAliases?: AliasOption,\n// ) => {\n// const { readTsConfigByFile, chalk } = await import('@modern-js/utils');\n// if (!userAliases) {\n// return;\n// }\n\n// const paths = Object.keys(\n// readTsConfigByFile(tsconfigAbsPath).compilerOptions?.paths || {},\n// ).map(key => key.replace(/\\/\\*$/, ''));\n\n// Object.keys(userAliases).forEach(name => {\n// if (paths.includes(name)) {\n// throw new Error(\n// chalk.red(\n// `It looks like you have configured the alias ${chalk.bold(\n// name,\n// )} in both the modern.config file and tsconfig.json.\\n Please remove the configuration in modern.config file and just keep the configuration in tsconfig.json.`,\n// ),\n// );\n// }\n// });\n// };\n\nexport const assignTsConfigPath = async (\n config: BaseBuildConfig,\n options: BuildCommandOptions,\n) => {\n const { defaultTsConfigPath } = await import('../constants/dts');\n\n // user run `build --tsconfig './tsconfig.build.json'`\n if (\n typeof options.tsconfig === 'string' &&\n options.tsconfig !== defaultTsConfigPath\n ) {\n config.dts = {\n only: false,\n distPath: './',\n abortOnError: true,\n ...(config.dts ?? {}),\n tsconfigPath: options.tsconfig,\n };\n }\n\n return config;\n};\n\nexport const printOrThrowDtsErrors = async (\n error: unknown,\n options: { abortOnError?: boolean; buildType: BuildType },\n) => {\n const { logger, chalk } = await import('@modern-js/utils');\n const { InternalDTSError } = await import('../error');\n const local = await import('../locale');\n const { abortOnError, buildType } = options ?? {};\n if (error instanceof Error) {\n if (abortOnError) {\n throw new InternalDTSError(error, {\n buildType,\n });\n } else {\n logger.warn(\n chalk.bgYellowBright(local.i18n.t(local.localeKeys.dts.abortOnError)),\n );\n logger.error(\n new InternalDTSError(error, {\n buildType,\n }),\n );\n }\n }\n};\n"]}
@@ -51,6 +51,7 @@ __export(libuildPlugins_exports, {
51
51
  watchPlugin: () => watchPlugin
52
52
  });
53
53
  module.exports = __toCommonJS(libuildPlugins_exports);
54
+ var import_logger = require("@modern-js/utils/logger");
54
55
  const watchPlugin = (api, config) => {
55
56
  return {
56
57
  name: "watch-plugin",
@@ -59,9 +60,7 @@ const watchPlugin = (api, config) => {
59
60
  const { watchSectionTitle } = yield Promise.resolve().then(() => __toESM(require("./log")));
60
61
  const { SectionTitleStatus } = yield Promise.resolve().then(() => __toESM(require("../constants/log")));
61
62
  const titleText = `[${config.buildType === "bundle" ? "Bundle" : "Bundleless"}:${config.format}_${config.target}]`;
62
- console.info(
63
- yield watchSectionTitle(titleText, SectionTitleStatus.Log)
64
- );
63
+ import_logger.logger.info(yield watchSectionTitle(titleText, SectionTitleStatus.Log));
65
64
  const runner = api.useHookRunners();
66
65
  runner.buildWatchJs({ buildConfig: config });
67
66
  }));
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,cAAc,CACzB,KACA,WACkB;AAClB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM,UAAU;AACd,eAAS,MAAM,YAAY,IAAI,gBAAgB,MAAY;AACzD,cAAM,EAAE,kBAAkB,IAAI,MAAM,6CAAO,OAAO;AAClD,cAAM,EAAE,mBAAmB,IAAI,MAAM,6CAAO,kBAAkB;AAC9D,cAAM,YAAY,IAChB,OAAO,cAAc,WAAW,WAAW,gBACzC,OAAO,UAAU,OAAO;AAC5B,gBAAQ;AAAA,UACN,MAAM,kBAAkB,WAAW,mBAAmB,GAAG;AAAA,QAC3D;AACA,cAAM,SAAS,IAAI,eAAe;AAClC,eAAO,aAAa,EAAE,aAAa,OAAO,CAAC;AAAA,MAC7C,EAAC;AAAA,IACH;AAAA,EACF;AACF;AAEO,MAAM,iBAAiB,CAC5B,QACA,YACkB;AAClB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM,UAAU;AACd,eAAS,MAAM,WAAW,WAAW,mBAAmB,MAAY;AAClE,cAAM,EAAE,kBAAkB,IAAI,MAAM,6CAAO,WAAW;AACtD,cAAM,iBAAiB,MAAM,kBAAkB,QAAQ,OAAO;AAC9D,iBAAS,OAAO,WAAW;AAAA,MAC7B,EAAC;AAAA,IACH;AAAA,EACF;AACF;;;;;;","names":[],"sources":["../../src/utils/libuildPlugins.ts"],"sourcesContent":["import type { LibuildPlugin } from '@modern-js/libuild';\nimport type { BaseBuildConfig, PluginAPI, ModuleTools } from '../types';\n\nexport const watchPlugin = (\n api: PluginAPI<ModuleTools>,\n config: BaseBuildConfig,\n): LibuildPlugin => {\n return {\n name: 'watch-plugin',\n apply(compiler) {\n compiler.hooks.watchChange.tap('watch-plugin', async () => {\n const { watchSectionTitle } = await import('./log');\n const { SectionTitleStatus } = await import('../constants/log');\n const titleText = `[${\n config.buildType === 'bundle' ? 'Bundle' : 'Bundleless'\n }:${config.format}_${config.target}]`;\n console.info(\n await watchSectionTitle(titleText, SectionTitleStatus.Log),\n );\n const runner = api.useHookRunners();\n runner.buildWatchJs({ buildConfig: config });\n });\n },\n };\n};\n\nexport const externalPlugin = (\n config: BaseBuildConfig,\n options: { appDirectory: string },\n): LibuildPlugin => {\n return {\n name: 'external-plugin',\n apply(compiler) {\n compiler.hooks.initialize.tapPromise('external-plugin', async () => {\n const { getFinalExternals } = await import('./builder');\n const finalExternals = await getFinalExternals(config, options);\n compiler.config.external = finalExternals;\n });\n },\n };\n};\n"]}
1
+ {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAuB;AAIhB,MAAM,cAAc,CACzB,KACA,WACkB;AAClB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM,UAAU;AACd,eAAS,MAAM,YAAY,IAAI,gBAAgB,MAAY;AACzD,cAAM,EAAE,kBAAkB,IAAI,MAAM,6CAAO,OAAO;AAClD,cAAM,EAAE,mBAAmB,IAAI,MAAM,6CAAO,kBAAkB;AAC9D,cAAM,YAAY,IAChB,OAAO,cAAc,WAAW,WAAW,gBACzC,OAAO,UAAU,OAAO;AAE5B,6BAAO,KAAK,MAAM,kBAAkB,WAAW,mBAAmB,GAAG,CAAC;AAEtE,cAAM,SAAS,IAAI,eAAe;AAClC,eAAO,aAAa,EAAE,aAAa,OAAO,CAAC;AAAA,MAC7C,EAAC;AAAA,IACH;AAAA,EACF;AACF;AAEO,MAAM,iBAAiB,CAC5B,QACA,YACkB;AAClB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM,UAAU;AACd,eAAS,MAAM,WAAW,WAAW,mBAAmB,MAAY;AAClE,cAAM,EAAE,kBAAkB,IAAI,MAAM,6CAAO,WAAW;AACtD,cAAM,iBAAiB,MAAM,kBAAkB,QAAQ,OAAO;AAC9D,iBAAS,OAAO,WAAW;AAAA,MAC7B,EAAC;AAAA,IACH;AAAA,EACF;AACF;;;;;;","names":[],"sources":["../../src/utils/libuildPlugins.ts"],"sourcesContent":["import { logger } from '@modern-js/utils/logger';\nimport type { LibuildPlugin } from '@modern-js/libuild';\nimport type { BaseBuildConfig, PluginAPI, ModuleTools } from '../types';\n\nexport const watchPlugin = (\n api: PluginAPI<ModuleTools>,\n config: BaseBuildConfig,\n): LibuildPlugin => {\n return {\n name: 'watch-plugin',\n apply(compiler) {\n compiler.hooks.watchChange.tap('watch-plugin', async () => {\n const { watchSectionTitle } = await import('./log');\n const { SectionTitleStatus } = await import('../constants/log');\n const titleText = `[${\n config.buildType === 'bundle' ? 'Bundle' : 'Bundleless'\n }:${config.format}_${config.target}]`;\n\n logger.info(await watchSectionTitle(titleText, SectionTitleStatus.Log));\n\n const runner = api.useHookRunners();\n runner.buildWatchJs({ buildConfig: config });\n });\n },\n };\n};\n\nexport const externalPlugin = (\n config: BaseBuildConfig,\n options: { appDirectory: string },\n): LibuildPlugin => {\n return {\n name: 'external-plugin',\n apply(compiler) {\n compiler.hooks.initialize.tapPromise('external-plugin', async () => {\n const { getFinalExternals } = await import('./builder');\n const finalExternals = await getFinalExternals(config, options);\n compiler.config.external = finalExternals;\n });\n },\n };\n};\n"]}
package/dist/utils/log.js CHANGED
@@ -54,15 +54,11 @@ var import_log = require("../constants/log");
54
54
  const watchSectionTitle = (str, status, detailLog) => __async(void 0, null, function* () {
55
55
  const { chalk } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
56
56
  if (status === import_log.SectionTitleStatus.Success) {
57
- return `${chalk.bgWhite.gray.underline(str)} ${chalk.green.underline(
58
- "Successful"
59
- )}`;
57
+ return `${chalk.gray(str)} ${chalk.green("Successful")}`;
60
58
  } else if (status === import_log.SectionTitleStatus.Fail) {
61
- return `${chalk.bgWhite.gray.underline(str)} ${chalk.red.underline(
62
- "Build Failed"
63
- )}`;
59
+ return `${chalk.gray(str)} ${chalk.red("Build Failed")}`;
64
60
  }
65
- return `${chalk.bgWhite.gray.underline(str)} ${detailLog ? detailLog : chalk.blue.underline("Log")}`;
61
+ return `${chalk.gray(str)} ${detailLog ? detailLog : "Log:"}`;
66
62
  });
67
63
  // Annotate the CommonJS export names for ESM import in node:
68
64
  0 && (module.exports = {
@@ -1 +1 @@
1
- {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAmC;AAE5B,MAAM,oBAAoB,CAC/B,KACA,QACA,cACG;AACH,QAAM,EAAE,MAAM,IAAI,MAAM,6CAAO,kBAAkB;AACjD,MAAI,WAAW,8BAAmB,SAAS;AACzC,WAAO,GAAG,MAAM,QAAQ,KAAK,UAAU,GAAG,KAAK,MAAM,MAAM;AAAA,MACzD;AAAA,IACF;AAAA,EACF,WAAW,WAAW,8BAAmB,MAAM;AAC7C,WAAO,GAAG,MAAM,QAAQ,KAAK,UAAU,GAAG,KAAK,MAAM,IAAI;AAAA,MACvD;AAAA,IACF;AAAA,EACF;AAEA,SAAO,GAAG,MAAM,QAAQ,KAAK,UAAU,GAAG,KACxC,YAAY,YAAY,MAAM,KAAK,UAAU,KAAK;AAEtD;;;;;","names":[],"sources":["../../src/utils/log.ts"],"sourcesContent":["import { SectionTitleStatus } from '../constants/log';\n\nexport const watchSectionTitle = async (\n str: string,\n status: SectionTitleStatus,\n detailLog?: string,\n) => {\n const { chalk } = await import('@modern-js/utils');\n if (status === SectionTitleStatus.Success) {\n return `${chalk.bgWhite.gray.underline(str)} ${chalk.green.underline(\n 'Successful',\n )}`;\n } else if (status === SectionTitleStatus.Fail) {\n return `${chalk.bgWhite.gray.underline(str)} ${chalk.red.underline(\n 'Build Failed',\n )}`;\n }\n\n return `${chalk.bgWhite.gray.underline(str)} ${\n detailLog ? detailLog : chalk.blue.underline('Log')\n }`;\n};\n"]}
1
+ {"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAmC;AAE5B,MAAM,oBAAoB,CAC/B,KACA,QACA,cACG;AACH,QAAM,EAAE,MAAM,IAAI,MAAM,6CAAO,kBAAkB;AACjD,MAAI,WAAW,8BAAmB,SAAS;AACzC,WAAO,GAAG,MAAM,KAAK,GAAG,KAAK,MAAM,MAAM,YAAY;AAAA,EACvD,WAAW,WAAW,8BAAmB,MAAM;AAC7C,WAAO,GAAG,MAAM,KAAK,GAAG,KAAK,MAAM,IAAI,cAAc;AAAA,EACvD;AAEA,SAAO,GAAG,MAAM,KAAK,GAAG,KAAK,YAAY,YAAY;AACvD;;;;;","names":[],"sources":["../../src/utils/log.ts"],"sourcesContent":["import { SectionTitleStatus } from '../constants/log';\n\nexport const watchSectionTitle = async (\n str: string,\n status: SectionTitleStatus,\n detailLog?: string,\n) => {\n const { chalk } = await import('@modern-js/utils');\n if (status === SectionTitleStatus.Success) {\n return `${chalk.gray(str)} ${chalk.green('Successful')}`;\n } else if (status === SectionTitleStatus.Fail) {\n return `${chalk.gray(str)} ${chalk.red('Build Failed')}`;\n }\n\n return `${chalk.gray(str)} ${detailLog ? detailLog : 'Log:'}`;\n};\n"]}