@modern-js/module-tools 2.4.0 → 2.5.0-beta.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.
- package/dist/builder/build.js +3 -2
- package/dist/builder/build.js.map +1 -1
- package/dist/config/schema.d.ts +68 -0
- package/dist/config/schema.js +16 -0
- package/dist/config/schema.js.map +1 -1
- package/dist/constants/build.js +2 -1
- package/dist/constants/build.js.map +1 -1
- package/dist/types/config/index.d.ts +3 -1
- package/dist/types/config/index.js.map +1 -1
- package/dist/utils/config.js +6 -5
- package/dist/utils/config.js.map +1 -1
- package/package.json +9 -9
package/dist/builder/build.js
CHANGED
|
@@ -156,7 +156,8 @@ const buildLib = (config, api, options) => __async(void 0, null, function* () {
|
|
|
156
156
|
externals,
|
|
157
157
|
autoExternal,
|
|
158
158
|
dts,
|
|
159
|
-
metafile
|
|
159
|
+
metafile,
|
|
160
|
+
sideEffects
|
|
160
161
|
} = config;
|
|
161
162
|
const { appDirectory } = api.useAppContext();
|
|
162
163
|
const { slash } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
@@ -226,8 +227,8 @@ const buildLib = (config, api, options) => __async(void 0, null, function* () {
|
|
|
226
227
|
external: externals,
|
|
227
228
|
autoExternal,
|
|
228
229
|
bundle: buildType === "bundle",
|
|
230
|
+
sideEffects,
|
|
229
231
|
outbase: sourceDir,
|
|
230
|
-
logLevel: "error",
|
|
231
232
|
esbuildOptions: (options2) => __spreadProps(__spreadValues({}, options2), {
|
|
232
233
|
supported: {
|
|
233
234
|
"dynamic-import": !(["cjs", "umd"].includes(format) && buildType === "bundleless")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAqB;AAWd,MAAM,eAAe,CAC1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AA,IACT,UAAU;AAAA,IACV;AAAA,IACA,QAAQ,cAAc;AAAA,IAEtB,SAAS;AAAA,IACT,UAAU;AAAA,IACV,gBAAgB,CAACA,aAAkB,iCAC9BA,WAD8B;AAAA,MAEjC,WAAW;AAAA,QACT,kBAAkB,EAChB,CAAC,OAAO,KAAK,EAAE,SAAS,MAAM,KAAK,cAAc;AAAA,MAErD;AAAA,IACF;AAAA,EACF;AAEA,MAAI;AACF,UAAM,EAAE,UAAU,IAAI,MAAM,6CAAO;AAEnC,UAAM,SAAS,IAAI,eAAe;AAClC,UAAM,sBAAsB,MAAM,OAAO,cAAc,aAAa;AAAA,MAClE,QAAQ,OAAK;AAAA,IACf,CAAC;AAED,UAAM,UAAU,MAAM,UAAU,OAAO,mBAAmB;AAC1D,UAAM,QAAQ,MAAM;AAEpB,QAAI,OAAO;AACT,YAAM,EAAE,kBAAkB,IAAI,MAAM,6CAAO;AAC3C,YAAM,EAAE,mBAAmB,IAAI,MAAM,6CAAO;AAC5C,YAAM,YAAY,IAChB,cAAc,WAAW,WAAW,iBACjC,UAAU;AAEf,cAAQ;AAAA,QACN,MAAM,kBAAkB,WAAW,mBAAmB,OAAO;AAAA,MAC/D;AAAA,IACF;AAAA,EACF,SAAS,GAAP;AACA,UAAM,EAAE,mBAAmB,IAAI,MAAM,6CAAO;AAC5C,UAAM,IAAI,mBAAmB,GAAG;AAAA,MAC9B;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AACF;;;;;;;;;","names":["options"],"sources":["../../src/builder/build.ts"],"sourcesContent":["import { join } from 'path';\nimport type { CLIConfig } from '@modern-js/libuild';\nimport type {\n BuildCommandOptions,\n BaseBuildConfig,\n ModuleTools,\n PluginAPI,\n DTSOptions,\n ModuleContext,\n} from '../types';\n\nexport const runBuildTask = async (\n options: {\n buildConfig: BaseBuildConfig;\n buildCmdOptions: BuildCommandOptions;\n context: ModuleContext;\n },\n api: PluginAPI<ModuleTools>,\n) => {\n const { buildConfig, context } = options;\n const { appDirectory, isTsProject } = context;\n\n if (isTsProject) {\n await buildInTsProject(options, api);\n } else {\n await buildInJsProject(options, api);\n }\n\n const { copyTask } = await import('./copy');\n await copyTask(buildConfig, { appDirectory });\n};\n\nexport const buildInTsProject = async (\n options: {\n buildConfig: BaseBuildConfig;\n buildCmdOptions: BuildCommandOptions;\n context: ModuleContext;\n },\n api: PluginAPI<ModuleTools>,\n) => {\n const { buildConfig, buildCmdOptions } = options;\n const dts = buildCmdOptions.dts ? buildConfig.dts : false;\n const skipBuildLib = buildConfig.dts ? buildConfig.dts.only : false;\n const watch = buildCmdOptions.watch ?? false;\n\n if (dts === false) {\n // --no-dts and buildConfig is `{ dts: { only: true } }`, then skip.\n !skipBuildLib && (await buildLib(buildConfig, api, { watch }));\n } else {\n const tasks = dts.only ? [generatorDts] : [buildLib, generatorDts];\n const { default: pMap } = await import('../../compiled/p-map');\n await pMap(tasks, async task => {\n await task(buildConfig, api as any, { watch, dts });\n });\n }\n};\n\nexport const buildInJsProject = async (\n options: {\n buildConfig: BaseBuildConfig;\n buildCmdOptions: BuildCommandOptions;\n context: ModuleContext;\n },\n api: PluginAPI<ModuleTools>,\n) => {\n const { buildConfig, buildCmdOptions } = options;\n const dts = buildCmdOptions.dts ? buildConfig.dts : false;\n const watch = buildCmdOptions.watch ?? false;\n\n if (dts !== false && dts.only) {\n return;\n }\n\n await buildLib(buildConfig, api, { watch });\n};\n\nexport const generatorDts = async (\n config: BaseBuildConfig,\n api: PluginAPI<ModuleTools>,\n options: {\n watch: boolean;\n dts: DTSOptions;\n },\n) => {\n const { runRollup, runTsc } = await import('./dts');\n const { watch, dts } = options;\n const { buildType, input, sourceDir, alias } = config;\n const { appDirectory } = api.useAppContext();\n const { tsconfigPath, distPath } = dts;\n if (buildType === 'bundle') {\n const { getFinalExternals } = await import('../utils/builder');\n const finalExternals = await getFinalExternals(config, { appDirectory });\n\n await runRollup(api, {\n distDir: distPath,\n watch,\n externals: finalExternals,\n input,\n tsconfigPath,\n });\n } else {\n await runTsc(api, {\n appDirectory,\n alias,\n distAbsPath: distPath,\n watch,\n tsconfigPath,\n sourceDir,\n });\n }\n};\n\nexport const buildLib = async (\n config: BaseBuildConfig,\n api: PluginAPI<ModuleTools>,\n options: {\n watch: boolean;\n },\n) => {\n const { watch } = options;\n const {\n target,\n buildType,\n sourceMap,\n format,\n outDir: distPath,\n asset,\n jsx,\n input,\n platform,\n splitting,\n minify,\n sourceDir,\n umdGlobals,\n umdModuleName,\n define,\n alias,\n style,\n externals,\n autoExternal,\n dts,\n metafile,\n } = config;\n const { appDirectory } = api.useAppContext();\n const { slash } = await import('@modern-js/utils');\n const root = slash(appDirectory);\n const outdir = slash(distPath);\n const assetOutDir = asset.path ? slash(asset.path) : asset.path;\n const { less, sass, postcss, inject, modules, autoModules } = style;\n\n // support es5,umd and emitDecoratorMetadata by swc\n const { es5Plugin, umdPlugin, transformPlugin } = await import(\n '@modern-js/libuild-plugin-swc'\n );\n const plugins = format === 'umd' ? [umdPlugin(umdModuleName)] : [];\n if (target === 'es5') {\n plugins.push(es5Plugin());\n }\n const { getProjectTsconfig } = await import('./dts/tsc');\n const tsconfigPath = dts\n ? dts.tsconfigPath\n : join(appDirectory, './tsconfig.json');\n const userTsconfig = await getProjectTsconfig(tsconfigPath);\n if (userTsconfig?.compilerOptions?.emitDecoratorMetadata) {\n plugins.push(\n transformPlugin({\n jsc: {\n transform: {\n legacyDecorator: true,\n decoratorMetadata: true,\n },\n },\n }),\n );\n }\n\n // support svgr\n if (asset.svgr) {\n const { svgrPlugin } = await import('@modern-js/libuild-plugin-svgr');\n const options = typeof asset.svgr === 'boolean' ? {} : asset.svgr;\n plugins.push(svgrPlugin(options));\n }\n\n // adapt module tools\n const { watchPlugin, externalPlugin } = await import(\n '../utils/libuild-plugins'\n );\n plugins.push(watchPlugin(api, config));\n plugins.push(externalPlugin(config, { appDirectory }));\n\n const buildConfig: CLIConfig = {\n root,\n watch,\n target,\n sourceMap,\n format,\n outdir,\n define,\n style: {\n less,\n sass,\n postcss,\n inject,\n modules,\n autoModules,\n },\n resolve: {\n alias,\n },\n asset: {\n ...asset,\n outdir: assetOutDir,\n },\n plugins,\n jsx,\n input,\n platform,\n splitting,\n minify,\n sourceDir,\n metafile: metafile && buildType === 'bundle',\n globals: umdGlobals,\n external: externals,\n autoExternal,\n bundle: buildType === 'bundle',\n // outbase for [dir]/[name]\n outbase: sourceDir,\n logLevel: 'error',\n esbuildOptions: (options: any) => ({\n ...options,\n supported: {\n 'dynamic-import': !(\n ['cjs', 'umd'].includes(format) && buildType === 'bundleless'\n ),\n },\n }),\n };\n\n try {\n const { Libuilder } = await import('@modern-js/libuild');\n\n const runner = api.useHookRunners();\n const modifiedBuildConfig = await runner.modifyLibuild(buildConfig, {\n onLast: c => c,\n });\n\n const builder = await Libuilder.create(modifiedBuildConfig);\n await builder.build();\n\n if (watch) {\n const { watchSectionTitle } = await import('../utils/log');\n const { SectionTitleStatus } = await import('../constants/log');\n const titleText = `[${\n buildType === 'bundle' ? 'Bundle' : 'Bundleless'\n }: ${format}_${target}]`;\n\n console.info(\n await watchSectionTitle(titleText, SectionTitleStatus.Success),\n );\n }\n } catch (e: any) {\n const { InternalBuildError } = await import('../error');\n throw new InternalBuildError(e, {\n target,\n format,\n buildType,\n });\n }\n};\n"]}
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAqB;AAWd,MAAM,eAAe,CAC1B,SAKA,QACG;AACH,QAAM,EAAE,aAAa,QAAQ,IAAI;AACjC,QAAM,EAAE,cAAc,YAAY,IAAI;AAEtC,MAAI,aAAa;AACf,UAAM,iBAAiB,SAAS,GAAG;AAAA,EACrC,OAAO;AACL,UAAM,iBAAiB,SAAS,GAAG;AAAA,EACrC;AAEA,QAAM,EAAE,SAAS,IAA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,cAAc;AAAA,MAErD;AAAA,IACF;AAAA,EACF;AAEA,MAAI;AACF,UAAM,EAAE,UAAU,IAAI,MAAM,6CAAO;AAEnC,UAAM,SAAS,IAAI,eAAe;AAClC,UAAM,sBAAsB,MAAM,OAAO,cAAc,aAAa;AAAA,MAClE,QAAQ,OAAK;AAAA,IACf,CAAC;AAED,UAAM,UAAU,MAAM,UAAU,OAAO,mBAAmB;AAC1D,UAAM,QAAQ,MAAM;AAEpB,QAAI,OAAO;AACT,YAAM,EAAE,kBAAkB,IAAI,MAAM,6CAAO;AAC3C,YAAM,EAAE,mBAAmB,IAAI,MAAM,6CAAO;AAC5C,YAAM,YAAY,IAChB,cAAc,WAAW,WAAW,iBACjC,UAAU;AAEf,cAAQ;AAAA,QACN,MAAM,kBAAkB,WAAW,mBAAmB,OAAO;AAAA,MAC/D;AAAA,IACF;AAAA,EACF,SAAS,GAAP;AACA,UAAM,EAAE,mBAAmB,IAAI,MAAM,6CAAO;AAC5C,UAAM,IAAI,mBAAmB,GAAG;AAAA,MAC9B;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AACF;;;;;;;;;","names":["options"],"sources":["../../src/builder/build.ts"],"sourcesContent":["import { join } from 'path';\nimport type { CLIConfig } from '@modern-js/libuild';\nimport type {\n BuildCommandOptions,\n BaseBuildConfig,\n ModuleTools,\n PluginAPI,\n DTSOptions,\n ModuleContext,\n} from '../types';\n\nexport const runBuildTask = async (\n options: {\n buildConfig: BaseBuildConfig;\n buildCmdOptions: BuildCommandOptions;\n context: ModuleContext;\n },\n api: PluginAPI<ModuleTools>,\n) => {\n const { buildConfig, context } = options;\n const { appDirectory, isTsProject } = context;\n\n if (isTsProject) {\n await buildInTsProject(options, api);\n } else {\n await buildInJsProject(options, api);\n }\n\n const { copyTask } = await import('./copy');\n await copyTask(buildConfig, { appDirectory });\n};\n\nexport const buildInTsProject = async (\n options: {\n buildConfig: BaseBuildConfig;\n buildCmdOptions: BuildCommandOptions;\n context: ModuleContext;\n },\n api: PluginAPI<ModuleTools>,\n) => {\n const { buildConfig, buildCmdOptions } = options;\n const dts = buildCmdOptions.dts ? buildConfig.dts : false;\n const skipBuildLib = buildConfig.dts ? buildConfig.dts.only : false;\n const watch = buildCmdOptions.watch ?? false;\n\n if (dts === false) {\n // --no-dts and buildConfig is `{ dts: { only: true } }`, then skip.\n !skipBuildLib && (await buildLib(buildConfig, api, { watch }));\n } else {\n const tasks = dts.only ? [generatorDts] : [buildLib, generatorDts];\n const { default: pMap } = await import('../../compiled/p-map');\n await pMap(tasks, async task => {\n await task(buildConfig, api as any, { watch, dts });\n });\n }\n};\n\nexport const buildInJsProject = async (\n options: {\n buildConfig: BaseBuildConfig;\n buildCmdOptions: BuildCommandOptions;\n context: ModuleContext;\n },\n api: PluginAPI<ModuleTools>,\n) => {\n const { buildConfig, buildCmdOptions } = options;\n const dts = buildCmdOptions.dts ? buildConfig.dts : false;\n const watch = buildCmdOptions.watch ?? false;\n\n if (dts !== false && dts.only) {\n return;\n }\n\n await buildLib(buildConfig, api, { watch });\n};\n\nexport const generatorDts = async (\n config: BaseBuildConfig,\n api: PluginAPI<ModuleTools>,\n options: {\n watch: boolean;\n dts: DTSOptions;\n },\n) => {\n const { runRollup, runTsc } = await import('./dts');\n const { watch, dts } = options;\n const { buildType, input, sourceDir, alias } = config;\n const { appDirectory } = api.useAppContext();\n const { tsconfigPath, distPath } = dts;\n if (buildType === 'bundle') {\n const { getFinalExternals } = await import('../utils/builder');\n const finalExternals = await getFinalExternals(config, { appDirectory });\n\n await runRollup(api, {\n distDir: distPath,\n watch,\n externals: finalExternals,\n input,\n tsconfigPath,\n });\n } else {\n await runTsc(api, {\n appDirectory,\n alias,\n distAbsPath: distPath,\n watch,\n tsconfigPath,\n sourceDir,\n });\n }\n};\n\nexport const buildLib = async (\n config: BaseBuildConfig,\n api: PluginAPI<ModuleTools>,\n options: {\n watch: boolean;\n },\n) => {\n const { watch } = options;\n const {\n target,\n buildType,\n sourceMap,\n format,\n outDir: distPath,\n asset,\n jsx,\n input,\n platform,\n splitting,\n minify,\n sourceDir,\n umdGlobals,\n umdModuleName,\n define,\n alias,\n style,\n externals,\n autoExternal,\n dts,\n metafile,\n sideEffects,\n } = config;\n const { appDirectory } = api.useAppContext();\n const { slash } = await import('@modern-js/utils');\n const root = slash(appDirectory);\n const outdir = slash(distPath);\n const assetOutDir = asset.path ? slash(asset.path) : asset.path;\n const { less, sass, postcss, inject, modules, autoModules } = style;\n\n // support es5,umd and emitDecoratorMetadata by swc\n const { es5Plugin, umdPlugin, transformPlugin } = await import(\n '@modern-js/libuild-plugin-swc'\n );\n const plugins = format === 'umd' ? [umdPlugin(umdModuleName)] : [];\n if (target === 'es5') {\n plugins.push(es5Plugin());\n }\n const { getProjectTsconfig } = await import('./dts/tsc');\n const tsconfigPath = dts\n ? dts.tsconfigPath\n : join(appDirectory, './tsconfig.json');\n const userTsconfig = await getProjectTsconfig(tsconfigPath);\n if (userTsconfig?.compilerOptions?.emitDecoratorMetadata) {\n plugins.push(\n transformPlugin({\n jsc: {\n transform: {\n legacyDecorator: true,\n decoratorMetadata: true,\n },\n },\n }),\n );\n }\n\n // support svgr\n if (asset.svgr) {\n const { svgrPlugin } = await import('@modern-js/libuild-plugin-svgr');\n const options = typeof asset.svgr === 'boolean' ? {} : asset.svgr;\n plugins.push(svgrPlugin(options));\n }\n\n // adapt module tools\n const { watchPlugin, externalPlugin } = await import(\n '../utils/libuild-plugins'\n );\n plugins.push(watchPlugin(api, config));\n plugins.push(externalPlugin(config, { appDirectory }));\n\n const buildConfig: CLIConfig = {\n root,\n watch,\n target,\n sourceMap,\n format,\n outdir,\n define,\n style: {\n less,\n sass,\n postcss,\n inject,\n modules,\n autoModules,\n },\n resolve: {\n alias,\n },\n asset: {\n ...asset,\n outdir: assetOutDir,\n },\n plugins,\n jsx,\n input,\n platform,\n splitting,\n minify,\n sourceDir,\n metafile: metafile && buildType === 'bundle',\n globals: umdGlobals,\n external: externals,\n autoExternal,\n bundle: buildType === 'bundle',\n sideEffects,\n // outbase for [dir]/[name]\n outbase: sourceDir,\n esbuildOptions: (options: any) => ({\n ...options,\n supported: {\n 'dynamic-import': !(\n ['cjs', 'umd'].includes(format) && buildType === 'bundleless'\n ),\n },\n }),\n };\n\n try {\n const { Libuilder } = await import('@modern-js/libuild');\n\n const runner = api.useHookRunners();\n const modifiedBuildConfig = await runner.modifyLibuild(buildConfig, {\n onLast: c => c,\n });\n\n const builder = await Libuilder.create(modifiedBuildConfig);\n await builder.build();\n\n if (watch) {\n const { watchSectionTitle } = await import('../utils/log');\n const { SectionTitleStatus } = await import('../constants/log');\n const titleText = `[${\n buildType === 'bundle' ? 'Bundle' : 'Bundleless'\n }: ${format}_${target}]`;\n\n console.info(\n await watchSectionTitle(titleText, SectionTitleStatus.Success),\n );\n }\n } catch (e: any) {\n const { InternalBuildError } = await import('../error');\n throw new InternalBuildError(e, {\n target,\n format,\n buildType,\n });\n }\n};\n"]}
|
package/dist/config/schema.d.ts
CHANGED
|
@@ -153,6 +153,23 @@ export declare const buildConfig: {
|
|
|
153
153
|
instanceof?: undefined;
|
|
154
154
|
})[];
|
|
155
155
|
};
|
|
156
|
+
sideEffects: {
|
|
157
|
+
anyOf: ({
|
|
158
|
+
type: string;
|
|
159
|
+
items: {
|
|
160
|
+
instanceof: string;
|
|
161
|
+
};
|
|
162
|
+
instanceof?: undefined;
|
|
163
|
+
} | {
|
|
164
|
+
type: string;
|
|
165
|
+
items?: undefined;
|
|
166
|
+
instanceof?: undefined;
|
|
167
|
+
} | {
|
|
168
|
+
instanceof: string;
|
|
169
|
+
type?: undefined;
|
|
170
|
+
items?: undefined;
|
|
171
|
+
})[];
|
|
172
|
+
};
|
|
156
173
|
};
|
|
157
174
|
}[];
|
|
158
175
|
};
|
|
@@ -302,6 +319,23 @@ export declare const buildConfig: {
|
|
|
302
319
|
instanceof?: undefined;
|
|
303
320
|
})[];
|
|
304
321
|
};
|
|
322
|
+
sideEffects: {
|
|
323
|
+
anyOf: ({
|
|
324
|
+
type: string;
|
|
325
|
+
items: {
|
|
326
|
+
instanceof: string;
|
|
327
|
+
};
|
|
328
|
+
instanceof?: undefined;
|
|
329
|
+
} | {
|
|
330
|
+
type: string;
|
|
331
|
+
items?: undefined;
|
|
332
|
+
instanceof?: undefined;
|
|
333
|
+
} | {
|
|
334
|
+
instanceof: string;
|
|
335
|
+
type?: undefined;
|
|
336
|
+
items?: undefined;
|
|
337
|
+
})[];
|
|
338
|
+
};
|
|
305
339
|
};
|
|
306
340
|
};
|
|
307
341
|
};
|
|
@@ -479,6 +513,23 @@ export declare const schema: ({
|
|
|
479
513
|
instanceof?: undefined;
|
|
480
514
|
})[];
|
|
481
515
|
};
|
|
516
|
+
sideEffects: {
|
|
517
|
+
anyOf: ({
|
|
518
|
+
type: string;
|
|
519
|
+
items: {
|
|
520
|
+
instanceof: string;
|
|
521
|
+
};
|
|
522
|
+
instanceof?: undefined;
|
|
523
|
+
} | {
|
|
524
|
+
type: string;
|
|
525
|
+
items?: undefined;
|
|
526
|
+
instanceof?: undefined;
|
|
527
|
+
} | {
|
|
528
|
+
instanceof: string;
|
|
529
|
+
type?: undefined;
|
|
530
|
+
items?: undefined;
|
|
531
|
+
})[];
|
|
532
|
+
};
|
|
482
533
|
};
|
|
483
534
|
}[];
|
|
484
535
|
};
|
|
@@ -628,6 +679,23 @@ export declare const schema: ({
|
|
|
628
679
|
instanceof?: undefined;
|
|
629
680
|
})[];
|
|
630
681
|
};
|
|
682
|
+
sideEffects: {
|
|
683
|
+
anyOf: ({
|
|
684
|
+
type: string;
|
|
685
|
+
items: {
|
|
686
|
+
instanceof: string;
|
|
687
|
+
};
|
|
688
|
+
instanceof?: undefined;
|
|
689
|
+
} | {
|
|
690
|
+
type: string;
|
|
691
|
+
items?: undefined;
|
|
692
|
+
instanceof?: undefined;
|
|
693
|
+
} | {
|
|
694
|
+
instanceof: string;
|
|
695
|
+
type?: undefined;
|
|
696
|
+
items?: undefined;
|
|
697
|
+
})[];
|
|
698
|
+
};
|
|
631
699
|
};
|
|
632
700
|
};
|
|
633
701
|
};
|
package/dist/config/schema.js
CHANGED
|
@@ -173,6 +173,22 @@ const buildConfigProperties = {
|
|
|
173
173
|
typeof: "string"
|
|
174
174
|
}
|
|
175
175
|
]
|
|
176
|
+
},
|
|
177
|
+
sideEffects: {
|
|
178
|
+
anyOf: [
|
|
179
|
+
{
|
|
180
|
+
type: "array",
|
|
181
|
+
items: {
|
|
182
|
+
instanceof: "RegExp"
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
type: "boolean"
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
instanceof: "Function"
|
|
190
|
+
}
|
|
191
|
+
]
|
|
176
192
|
}
|
|
177
193
|
};
|
|
178
194
|
const buildConfig = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA8MA,2BAA6B;AA9MtB,MAAM,UAAU;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;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;AACP;AACA,MAAM,wBAAwB;AAAA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AAA,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];\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 './legacy-schema';\n"]}
|
package/dist/constants/build.js
CHANGED
|
@@ -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;
|
|
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"]}
|
|
@@ -28,7 +28,8 @@ export type AutoExternal = boolean | {
|
|
|
28
28
|
};
|
|
29
29
|
export type JSX = 'automatic' | 'transform';
|
|
30
30
|
export type AliasOption = Record<string, string> | ((aliases: Record<string, string>) => Record<string, string> | void);
|
|
31
|
-
export type BaseBuildConfig = Omit<Required<PartialBaseBuildConfig>, 'dts' | 'style' | 'alias'> & {
|
|
31
|
+
export type BaseBuildConfig = Omit<Required<PartialBaseBuildConfig>, 'dts' | 'style' | 'alias' | 'sideEffects'> & {
|
|
32
|
+
sideEffects: LibuildUserConfig['sideEffects'];
|
|
32
33
|
dts: false | DTSOptions;
|
|
33
34
|
style: Omit<Required<LibuildStyle>, 'cleanCss'> & {
|
|
34
35
|
tailwindCss: TailwindCSSConfig;
|
|
@@ -58,6 +59,7 @@ export type PartialBaseBuildConfig = {
|
|
|
58
59
|
umdModuleName?: ((chunkName: string) => string) | string | undefined;
|
|
59
60
|
define?: LibuildUserConfig['define'];
|
|
60
61
|
style?: StyleConfig;
|
|
62
|
+
sideEffects?: LibuildUserConfig['sideEffects'];
|
|
61
63
|
};
|
|
62
64
|
export type BuildConfig = BaseBuildConfig | BaseBuildConfig[];
|
|
63
65
|
export type PartialBuildConfig = PartialBaseBuildConfig | PartialBaseBuildConfig[];
|
|
@@ -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/build-presets';\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'\n> & {\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};\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 }) => 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/build-presets';\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 }) => 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/utils/config.js
CHANGED
|
@@ -85,7 +85,7 @@ const validBuildTypeAndFormat = (config) => {
|
|
|
85
85
|
}
|
|
86
86
|
};
|
|
87
87
|
const mergeDefaultBaseConfig = (pConfig, context) => __async(void 0, null, function* () {
|
|
88
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
88
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
89
89
|
const { defaultBuildConfig: defaultConfig } = yield Promise.resolve().then(() => __toESM(require("../constants/build")));
|
|
90
90
|
const { cloneDeep } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils/lodash")));
|
|
91
91
|
const { applyOptionsChain, ensureAbsolutePath, slash } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
@@ -136,15 +136,16 @@ const mergeDefaultBaseConfig = (pConfig, context) => __async(void 0, null, funct
|
|
|
136
136
|
autoExternal: (_o = pConfig.autoExternal) != null ? _o : defaultConfig.autoExternal,
|
|
137
137
|
umdGlobals: __spreadValues(__spreadValues({}, defaultConfig.umdGlobals), pConfig.umdGlobals),
|
|
138
138
|
umdModuleName: (_p = pConfig.umdModuleName) != null ? _p : defaultConfig.umdModuleName,
|
|
139
|
-
|
|
139
|
+
sideEffects: (_q = pConfig.sideEffects) != null ? _q : defaultConfig.sideEffects,
|
|
140
|
+
externals: (_r = pConfig.externals) != null ? _r : defaultConfig.externals,
|
|
140
141
|
sourceDir,
|
|
141
142
|
alias,
|
|
142
143
|
define,
|
|
143
144
|
metafile,
|
|
144
145
|
style: __spreadProps(__spreadValues({}, styleConfig), {
|
|
145
|
-
inject: (
|
|
146
|
-
modules: (
|
|
147
|
-
autoModules: (
|
|
146
|
+
inject: (_t = (_s = pConfig.style) == null ? void 0 : _s.inject) != null ? _t : defaultConfig.style.inject,
|
|
147
|
+
modules: (_v = (_u = pConfig.style) == null ? void 0 : _u.modules) != null ? _v : defaultConfig.style.modules,
|
|
148
|
+
autoModules: (_x = (_w = pConfig.style) == null ? void 0 : _w.autoModules) != null ? _x : defaultConfig.style.autoModules,
|
|
148
149
|
tailwindCss: defaultConfig.style.tailwindCss
|
|
149
150
|
})
|
|
150
151
|
};
|
package/dist/utils/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASO,MAAM,0BAA0B,CAAC,WAA+B;AACrE,MAAI,MAAM,QAAQ,MAAM,GAAG;AACzB,eAAW,KAAK,QAAQ;AACtB,8BAAwB,CAAC;AAAA,IAC3B;AAAA,EACF,OAAO;AACL,4BAAwB,MAAM;AAAA,EAChC;AACF;AAEO,MAAM,0BAA0B,CAAC,WAAmC;AAnB3E;AAoBE,MACE,OAAO,cAAc,gBACrB,CAAC,QAAQ,KAAK,EAAE,UAAS,YAAO,WAAP,YAAiB,EAAE,GAC5C;AACA,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACF;AAEO,MAAM,yBAAyB,CACpC,SACA,YAC6B;AAjC/B;AAkCE,QAAM,EAAE,oBAAoB,cAAc,IAAI,MAAM,6CAClD;AAEF,QAAM,EAAE,UAAU,IAAI,MAAM,6CAAO;AACnC,QAAM,EAAE,mBAAmB,oBAAoB,MAAM,IAAI,MAAM,6CAC7D;AAEF,QAAM,EAAE,qBAAqB,IAAI,MAAM,6CAAO;AAC9C,QAAM,EAAE,eAAe,IAAI,MAAM,6CAAO;AACxC,QAAM,eAAe;AAAA,IACnB,KAAK,QAAQ;AAAA,EACf;AACA,QAAM,cAAc,kBAAkB,cAAc,QAAQ,KAAK;AAOjE,QAAM,QAAQ,OAAO,KAAK,WAAW,EAAE;AAAA,IAC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aAAQ,aAAR,YAAoB,cAAc;AAAA,IAC5C,YAAW,aAAQ,cAAR,YAAqB,cAAc;AAAA,IAC9C,SAAQ,aAAQ,WAAR,YAAkB,cAAc;AAAA,IACxC,eAAc,aAAQ,iBAAR,YAAwB,cAAc;AAAA,IACpD,YAAY,kCACP,cAAc,aACd,QAAQ;AAAA,IAEb,gBAAe,aAAQ,kBAAR,YAAyB,cAAc;AAAA,IACtD,YAAW,aAAQ,cAAR,YAAqB,cAAc;AAAA,IAC9C;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,iCACF,cADE;AAAA,MAEL,SAAQ,mBAAQ,UAAR,mBAAe,WAAf,YAAyB,cAAc,MAAM;AAAA,MACrD,UAAS,mBAAQ,UAAR,mBAAe,YAAf,YAA0B,cAAc,MAAM;AAAA,MACvD,cACE,mBAAQ,UAAR,mBAAe,gBAAf,YAA8B,cAAc,MAAM;AAAA,MACpD,aAAa,cAAc,MAAM;AAAA,IACnC;AAAA,EACF;AACF;AAEO,MAAM,eAAe,CAC1B,SACA,eACG;AACH,QAAM,EAAE,WAAW,aAAa,SAAS,IAAI,MAAM,6CACjD;AAGF,MAAI,YAAY,OAAO,GAAG;AACxB,WAAO,UAAU,UAAU;AAAA,EAC7B;AAEA,MAAI,SAAS,OAAO,GAAG;AACrB,WAAO,kCACF,aACA;AAAA,EAEP;AAEA,SAAO;AACT;AAEO,MAAM,qBAAqB,CAAC,WAEK,QAAQ,OAAO,MAAM;;;;;;;;;","names":["value"],"sources":["../../src/utils/config.ts"],"sourcesContent":["import { ModuleContext } from '../types';\nimport type {\n BaseBuildConfig,\n PartialBuildConfig,\n PartialBaseBuildConfig,\n DTSOptions,\n ModuleLegacyUserConfig,\n} from '../types';\n\nexport const validPartialBuildConfig = (config: PartialBuildConfig) => {\n if (Array.isArray(config)) {\n for (const c of config) {\n validBuildTypeAndFormat(c);\n }\n } else {\n validBuildTypeAndFormat(config);\n }\n};\n\nexport const validBuildTypeAndFormat = (config: PartialBaseBuildConfig) => {\n if (\n config.buildType === 'bundleless' &&\n ['iife', 'umd'].includes(config.format ?? '')\n ) {\n throw new Error(\n `when buildType is bundleless, the format must be equal to one of the allowed values: (cjs, esm)`,\n );\n }\n};\n\nexport const mergeDefaultBaseConfig = async (\n pConfig: PartialBaseBuildConfig,\n context: ModuleContext,\n): Promise<BaseBuildConfig> => {\n const { defaultBuildConfig: defaultConfig } = await import(\n '../constants/build'\n );\n const { cloneDeep } = await import('@modern-js/utils/lodash');\n const { applyOptionsChain, ensureAbsolutePath, slash } = await import(\n '@modern-js/utils'\n );\n const { getDefaultIndexEntry } = await import('./input');\n const { getStyleConfig } = await import('./style');\n const defaultAlias = {\n '@': context.srcDirectory,\n };\n const mergedAlias = applyOptionsChain(defaultAlias, pConfig.alias);\n\n /**\n * Format alias value:\n * - Relative paths need to be turned into absolute paths.\n * - Absolute paths or a package name are not processed.\n */\n const alias = Object.keys(mergedAlias).reduce<Record<string, string>>(\n (prev, name) => {\n const formattedValue = (value: string) => {\n if (typeof value === 'string' && value.startsWith('.')) {\n return slash(ensureAbsolutePath(context.appDirectory, value));\n }\n return value;\n };\n const value = formattedValue(mergedAlias[name]);\n\n prev[name] = value;\n return prev;\n },\n {},\n );\n\n const styleConfig = await getStyleConfig(pConfig);\n const buildType = pConfig.buildType ?? defaultConfig.buildType;\n const sourceDir = pConfig.sourceDir ?? defaultConfig.sourceDir;\n const metafile = pConfig.metafile ?? defaultConfig.metafile;\n const input =\n buildType === 'bundle' ? await getDefaultIndexEntry(context) : [sourceDir];\n const userDefine = pConfig.define ?? {};\n const define = {\n ...defaultConfig.define,\n ...Object.keys(userDefine).reduce<Record<string, string>>((memo, name) => {\n memo[name] = JSON.stringify(userDefine[name]!);\n return memo;\n }, {}),\n };\n return {\n asset: {\n ...defaultConfig.asset,\n ...pConfig.asset,\n },\n buildType,\n format: pConfig.format ?? defaultConfig.format,\n target: pConfig.target ?? defaultConfig.target,\n sourceMap: pConfig.sourceMap ?? defaultConfig.sourceMap,\n copy: pConfig.copy ?? cloneDeep(defaultConfig.copy),\n outDir: pConfig.outDir ?? defaultConfig.outDir,\n dts: await getDtsConfig(pConfig.dts, defaultConfig.dts as DTSOptions),\n jsx: pConfig.jsx ?? defaultConfig.jsx,\n input: pConfig.input ?? cloneDeep(input),\n platform: pConfig.platform ?? defaultConfig.platform,\n splitting: pConfig.splitting ?? defaultConfig.splitting,\n minify: pConfig.minify ?? defaultConfig.minify,\n autoExternal: pConfig.autoExternal ?? defaultConfig.autoExternal,\n umdGlobals: {\n ...defaultConfig.umdGlobals,\n ...pConfig.umdGlobals,\n },\n umdModuleName: pConfig.umdModuleName ?? defaultConfig.umdModuleName,\n externals: pConfig.externals ?? defaultConfig.externals,\n sourceDir,\n alias,\n define,\n metafile,\n style: {\n ...styleConfig,\n inject: pConfig.style?.inject ?? defaultConfig.style.inject,\n modules: pConfig.style?.modules ?? defaultConfig.style.modules,\n autoModules:\n pConfig.style?.autoModules ?? defaultConfig.style.autoModules,\n tailwindCss: defaultConfig.style.tailwindCss,\n },\n };\n};\n\nexport const getDtsConfig = async (\n userDTS: PartialBaseBuildConfig['dts'],\n defaultDTS: Required<DTSOptions>,\n) => {\n const { cloneDeep, isUndefined, isObject } = await import(\n '@modern-js/utils/lodash'\n );\n\n if (isUndefined(userDTS)) {\n return cloneDeep(defaultDTS);\n }\n\n if (isObject(userDTS)) {\n return {\n ...defaultDTS,\n ...userDTS,\n };\n }\n\n return userDTS;\n};\n\nexport const isLegacyUserConfig = (config: {\n legacy?: boolean;\n}): config is ModuleLegacyUserConfig => Boolean(config.legacy);\n"]}
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASO,MAAM,0BAA0B,CAAC,WAA+B;AACrE,MAAI,MAAM,QAAQ,MAAM,GAAG;AACzB,eA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ACrD,UAAS,mBAAQ,UAAR,mBAAe,YAAf,YAA0B,cAAc,MAAM;AAAA,MACvD,cACE,mBAAQ,UAAR,mBAAe,gBAAf,YAA8B,cAAc,MAAM;AAAA,MACpD,aAAa,cAAc,MAAM;AAAA,IACnC;AAAA,EACF;AACF;AAEO,MAAM,eAAe,CAC1B,SACA,eACG;AACH,QAAM,EAAE,WAAW,aAAa,SAAS,IAAI,MAAM,6CACjD;AAGF,MAAI,YAAY,OAAO,GAAG;AACxB,WAAO,UAAU,UAAU;AAAA,EAC7B;AAEA,MAAI,SAAS,OAAO,GAAG;AACrB,WAAO,kCACF,aACA;AAAA,EAEP;AAEA,SAAO;AACT;AAEO,MAAM,qBAAqB,CAAC,WAEK,QAAQ,OAAO,MAAM;;;;;;;;;","names":["value"],"sources":["../../src/utils/config.ts"],"sourcesContent":["import { ModuleContext } from '../types';\nimport type {\n BaseBuildConfig,\n PartialBuildConfig,\n PartialBaseBuildConfig,\n DTSOptions,\n ModuleLegacyUserConfig,\n} from '../types';\n\nexport const validPartialBuildConfig = (config: PartialBuildConfig) => {\n if (Array.isArray(config)) {\n for (const c of config) {\n validBuildTypeAndFormat(c);\n }\n } else {\n validBuildTypeAndFormat(config);\n }\n};\n\nexport const validBuildTypeAndFormat = (config: PartialBaseBuildConfig) => {\n if (\n config.buildType === 'bundleless' &&\n ['iife', 'umd'].includes(config.format ?? '')\n ) {\n throw new Error(\n `when buildType is bundleless, the format must be equal to one of the allowed values: (cjs, esm)`,\n );\n }\n};\n\nexport const mergeDefaultBaseConfig = async (\n pConfig: PartialBaseBuildConfig,\n context: ModuleContext,\n): Promise<BaseBuildConfig> => {\n const { defaultBuildConfig: defaultConfig } = await import(\n '../constants/build'\n );\n const { cloneDeep } = await import('@modern-js/utils/lodash');\n const { applyOptionsChain, ensureAbsolutePath, slash } = await import(\n '@modern-js/utils'\n );\n const { getDefaultIndexEntry } = await import('./input');\n const { getStyleConfig } = await import('./style');\n const defaultAlias = {\n '@': context.srcDirectory,\n };\n const mergedAlias = applyOptionsChain(defaultAlias, pConfig.alias);\n\n /**\n * Format alias value:\n * - Relative paths need to be turned into absolute paths.\n * - Absolute paths or a package name are not processed.\n */\n const alias = Object.keys(mergedAlias).reduce<Record<string, string>>(\n (prev, name) => {\n const formattedValue = (value: string) => {\n if (typeof value === 'string' && value.startsWith('.')) {\n return slash(ensureAbsolutePath(context.appDirectory, value));\n }\n return value;\n };\n const value = formattedValue(mergedAlias[name]);\n\n prev[name] = value;\n return prev;\n },\n {},\n );\n\n const styleConfig = await getStyleConfig(pConfig);\n const buildType = pConfig.buildType ?? defaultConfig.buildType;\n const sourceDir = pConfig.sourceDir ?? defaultConfig.sourceDir;\n const metafile = pConfig.metafile ?? defaultConfig.metafile;\n const input =\n buildType === 'bundle' ? await getDefaultIndexEntry(context) : [sourceDir];\n const userDefine = pConfig.define ?? {};\n const define = {\n ...defaultConfig.define,\n ...Object.keys(userDefine).reduce<Record<string, string>>((memo, name) => {\n memo[name] = JSON.stringify(userDefine[name]!);\n return memo;\n }, {}),\n };\n return {\n asset: {\n ...defaultConfig.asset,\n ...pConfig.asset,\n },\n buildType,\n format: pConfig.format ?? defaultConfig.format,\n target: pConfig.target ?? defaultConfig.target,\n sourceMap: pConfig.sourceMap ?? defaultConfig.sourceMap,\n copy: pConfig.copy ?? cloneDeep(defaultConfig.copy),\n outDir: pConfig.outDir ?? defaultConfig.outDir,\n dts: await getDtsConfig(pConfig.dts, defaultConfig.dts as DTSOptions),\n jsx: pConfig.jsx ?? defaultConfig.jsx,\n input: pConfig.input ?? cloneDeep(input),\n platform: pConfig.platform ?? defaultConfig.platform,\n splitting: pConfig.splitting ?? defaultConfig.splitting,\n minify: pConfig.minify ?? defaultConfig.minify,\n autoExternal: pConfig.autoExternal ?? defaultConfig.autoExternal,\n umdGlobals: {\n ...defaultConfig.umdGlobals,\n ...pConfig.umdGlobals,\n },\n umdModuleName: pConfig.umdModuleName ?? defaultConfig.umdModuleName,\n sideEffects: pConfig.sideEffects ?? defaultConfig.sideEffects,\n externals: pConfig.externals ?? defaultConfig.externals,\n sourceDir,\n alias,\n define,\n metafile,\n style: {\n ...styleConfig,\n inject: pConfig.style?.inject ?? defaultConfig.style.inject,\n modules: pConfig.style?.modules ?? defaultConfig.style.modules,\n autoModules:\n pConfig.style?.autoModules ?? defaultConfig.style.autoModules,\n tailwindCss: defaultConfig.style.tailwindCss,\n },\n };\n};\n\nexport const getDtsConfig = async (\n userDTS: PartialBaseBuildConfig['dts'],\n defaultDTS: Required<DTSOptions>,\n) => {\n const { cloneDeep, isUndefined, isObject } = await import(\n '@modern-js/utils/lodash'\n );\n\n if (isUndefined(userDTS)) {\n return cloneDeep(defaultDTS);\n }\n\n if (isObject(userDTS)) {\n return {\n ...defaultDTS,\n ...userDTS,\n };\n }\n\n return userDTS;\n};\n\nexport const isLegacyUserConfig = (config: {\n legacy?: boolean;\n}): config is ModuleLegacyUserConfig => Boolean(config.legacy);\n"]}
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"module-tools",
|
|
12
12
|
"lib-tools"
|
|
13
13
|
],
|
|
14
|
-
"version": "2.
|
|
14
|
+
"version": "2.5.0-beta.0",
|
|
15
15
|
"bin": {
|
|
16
16
|
"modern": "./bin/modern.js",
|
|
17
17
|
"modern-module": "./bin/modern.js"
|
|
@@ -36,19 +36,20 @@
|
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@modern-js/libuild": "~0.
|
|
40
|
-
"@modern-js/libuild-plugin-svgr": "~0.
|
|
41
|
-
"@modern-js/libuild-plugin-swc": "~0.
|
|
39
|
+
"@modern-js/libuild": "~0.10.0",
|
|
40
|
+
"@modern-js/libuild-plugin-svgr": "~0.10.0",
|
|
41
|
+
"@modern-js/libuild-plugin-swc": "~0.10.0",
|
|
42
42
|
"@modern-js/core": "2.4.0",
|
|
43
|
-
"@modern-js/new-action": "2.4.0",
|
|
44
43
|
"@modern-js/plugin": "2.4.0",
|
|
45
|
-
"@modern-js/
|
|
44
|
+
"@modern-js/new-action": "2.4.0",
|
|
46
45
|
"@modern-js/upgrade": "2.4.0",
|
|
46
|
+
"@modern-js/plugin-i18n": "2.4.0",
|
|
47
47
|
"@modern-js/utils": "2.4.0",
|
|
48
48
|
"@modern-js/plugin-changeset": "2.4.0",
|
|
49
49
|
"@modern-js/plugin-lint": "2.4.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
+
"@modern-js/self": "npm:@modern-js/module-tools@*",
|
|
52
53
|
"@types/jest": "^27",
|
|
53
54
|
"@types/node": "^14",
|
|
54
55
|
"@types/fs-extra": "9.0.13",
|
|
@@ -59,10 +60,9 @@
|
|
|
59
60
|
"postcss-alias": "2.0.0",
|
|
60
61
|
"react": "17",
|
|
61
62
|
"typescript": "^4",
|
|
62
|
-
"@modern-js/self": "npm:@modern-js/module-tools@2.4.0",
|
|
63
63
|
"@modern-js/builder-webpack-provider": "2.4.0",
|
|
64
|
-
"@scripts/
|
|
65
|
-
"@scripts/
|
|
64
|
+
"@scripts/build": "2.4.0",
|
|
65
|
+
"@scripts/jest-config": "2.4.0"
|
|
66
66
|
},
|
|
67
67
|
"publishConfig": {
|
|
68
68
|
"registry": "https://registry.npmjs.org/",
|