@modern-js/module-tools 2.21.1 → 2.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -0
- package/compiled/@rollup/plugin-json/@rollup/pluginutils/types/index.d.ts +8 -2
- package/compiled/@rollup/plugin-json/estree/index.d.ts +677 -548
- package/compiled/@rollup/plugin-json/index.js +1 -1
- package/compiled/@rollup/plugin-json/package.json +1 -1
- package/compiled/@rollup/plugin-json/rollup/dist/rollup.d.ts +167 -150
- package/compiled/@rollup/plugin-json/types/index.d.ts +2 -2
- package/compiled/rollup/249.index.js +103 -0
- package/compiled/rollup/index.js +36 -21
- package/compiled/rollup/package.json +1 -1
- package/compiled/rollup/types/rollup.d.ts +167 -150
- package/compiled/rollup-plugin-dts/dist/rollup-plugin-dts.d.ts +3 -105
- package/compiled/rollup-plugin-dts/index.js +1 -1
- package/compiled/rollup-plugin-dts/package.json +1 -1
- package/compiled/rollup-plugin-dts/rollup/dist/rollup.d.ts +167 -150
- package/dist/build.js +3 -1
- package/dist/build.js.map +1 -1
- package/dist/builder/build.js +37 -14
- package/dist/builder/build.js.map +1 -1
- package/dist/builder/clear.js +6 -2
- package/dist/builder/clear.js.map +1 -1
- package/dist/builder/copy.js +9 -3
- package/dist/builder/copy.js.map +1 -1
- package/dist/builder/dts/index.js +6 -2
- package/dist/builder/dts/index.js.map +1 -1
- package/dist/builder/dts/rollup.js +3 -1
- package/dist/builder/dts/rollup.js.map +1 -1
- package/dist/builder/dts/tsc.js +6 -2
- package/dist/builder/dts/tsc.js.map +1 -1
- package/dist/builder/index.js +3 -1
- package/dist/builder/index.js.map +1 -1
- package/dist/builder/platform.js +3 -1
- package/dist/builder/platform.js.map +1 -1
- package/dist/cli.js +3 -1
- package/dist/cli.js.map +1 -1
- package/dist/command.js +12 -4
- package/dist/command.js.map +1 -1
- package/dist/config/defineConfig.js +6 -2
- package/dist/config/defineConfig.js.map +1 -1
- package/dist/config/legacySchema.js +21 -7
- package/dist/config/legacySchema.js.map +1 -1
- package/dist/config/normalize.js +18 -6
- package/dist/config/normalize.js.map +1 -1
- package/dist/config/schema.js +21 -7
- package/dist/config/schema.js.map +1 -1
- package/dist/config/transformLegacyConfig.js +30 -10
- package/dist/config/transformLegacyConfig.js.map +1 -1
- package/dist/constants/build.js +3 -1
- package/dist/constants/build.js.map +1 -1
- package/dist/constants/buildPresets.js +54 -18
- package/dist/constants/buildPresets.js.map +1 -1
- package/dist/constants/colors.js +9 -3
- package/dist/constants/colors.js.map +1 -1
- package/dist/constants/dts.js +12 -4
- package/dist/constants/dts.js.map +1 -1
- package/dist/constants/file.js +9 -3
- package/dist/constants/file.js.map +1 -1
- package/dist/constants/legacyBuildPresets.js +18 -6
- package/dist/constants/legacyBuildPresets.js.map +1 -1
- package/dist/constants/log.js +21 -7
- package/dist/constants/log.js.map +1 -1
- package/dist/dev.js +6 -2
- package/dist/dev.js.map +1 -1
- package/dist/error.js +18 -6
- package/dist/error.js.map +1 -1
- package/dist/hooks/build.js +6 -2
- package/dist/hooks/build.js.map +1 -1
- package/dist/hooks/dev.js +3 -1
- package/dist/hooks/dev.js.map +1 -1
- package/dist/hooks/index.js +3 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/misc.js +3 -1
- package/dist/hooks/misc.js.map +1 -1
- package/dist/index.js +12 -4
- package/dist/index.js.map +1 -1
- package/dist/locale/en.js +3 -1
- package/dist/locale/en.js.map +1 -1
- package/dist/locale/index.js +6 -2
- package/dist/locale/index.js.map +1 -1
- package/dist/locale/zh.js +3 -1
- package/dist/locale/zh.js.map +1 -1
- package/dist/plugins.js +3 -1
- package/dist/plugins.js.map +1 -1
- package/dist/types/config/index.d.ts +3 -0
- package/dist/types/config/index.js.map +1 -1
- package/dist/utils/builder.js +15 -5
- package/dist/utils/builder.js.map +1 -1
- package/dist/utils/common.js +3 -1
- package/dist/utils/common.js.map +1 -1
- package/dist/utils/config.js +15 -5
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/context.js +3 -1
- package/dist/utils/context.js.map +1 -1
- package/dist/utils/dts.js +15 -5
- package/dist/utils/dts.js.map +1 -1
- package/dist/utils/input.js +15 -5
- package/dist/utils/input.js.map +1 -1
- package/dist/utils/language.js +3 -1
- package/dist/utils/language.js.map +1 -1
- package/dist/utils/libuildPlugins.js +6 -2
- package/dist/utils/libuildPlugins.js.map +1 -1
- package/dist/utils/log.js +3 -1
- package/dist/utils/log.js.map +1 -1
- package/dist/utils/onExit.js +3 -1
- package/dist/utils/onExit.js.map +1 -1
- package/dist/utils/path.js +3 -1
- package/dist/utils/path.js.map +1 -1
- package/dist/utils/print.js +21 -7
- package/dist/utils/print.js.map +1 -1
- package/dist/utils/style.js +12 -4
- package/dist/utils/style.js.map +1 -1
- package/dist/utils/tspathsTransform.js +3 -1
- package/dist/utils/tspathsTransform.js.map +1 -1
- package/package.json +16 -16
- package/compiled/@rollup/plugin-json/license +0 -21
package/dist/utils/builder.js
CHANGED
|
@@ -10,11 +10,21 @@ function _export(target, all) {
|
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
_export(exports, {
|
|
13
|
-
getFinalExternals: ()
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
getFinalExternals: function() {
|
|
14
|
+
return getFinalExternals;
|
|
15
|
+
},
|
|
16
|
+
getAllDeps: function() {
|
|
17
|
+
return getAllDeps;
|
|
18
|
+
},
|
|
19
|
+
checkSwcHelpers: function() {
|
|
20
|
+
return checkSwcHelpers;
|
|
21
|
+
},
|
|
22
|
+
matchSwcTransformCondition: function() {
|
|
23
|
+
return matchSwcTransformCondition;
|
|
24
|
+
},
|
|
25
|
+
matchEs5PluginCondition: function() {
|
|
26
|
+
return matchEs5PluginCondition;
|
|
27
|
+
}
|
|
18
28
|
});
|
|
19
29
|
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
20
30
|
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require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OC,KAAMP,KAAKL,oBAAsC,CAAC;;IAEhE;AAEA,WAAOF;EACT,SAASgB,GAAP;AACAC,mBAAOC,KAAK;AACZ,WAAO;EACT;AACF;AAEO,MAAM1B,kBAAkB,OAAOI,YAGhC;AACJ,QAAM,EAAEG,cAAcoB,gBAAe,IAAKvB;AAC1C,MAAIuB,oBAAoB,OAAO;AAC7B;EACF;AACA,QAAMnB,OAAO,MAAMT,WAAWQ,cAAc;IAC1CE,cAAc;IACdc,iBAAiB;EACnB;AACA,QAAMK,oBAAoB;AAC1B,MAAI,CAACpB,KAAKqB,SAASD,oBAAoB;AACrC,UAAME,QAAQ,MAAM,iFAAO;AAC3B,UAAM,IAAIC,MAAMD,MAAME,KAAKC,EAAEH,MAAMI,WAAWC,OAAOR,eAAe;EACtE;AACF;AAEO,MAAM1B,6BAA6B,CAACmC,oBAKrC;AACJ,QAAM,EAAEC,YAAYC,WAAWC,QAAQC,oBAAmB,IACxDJ;AAEF,MAAII,qBAAqB;AACvB,WAAO;EACT;AAMA,MAAIH,eAAe,YAAY;AAC7B,WAAO;EACT;AAEA,MAAIC,cAAc,cAAc;AAC9B,WAAO;EACT;AAEA,MAAIC,WAAW,SAASA,WAAW,QAAQ;AAEzC,WAAO;EACT;AAKA,SAAO;AACT;AAEO,MAAMrC,0BAA0B,CAACkC,oBAMlC;AACJ,QAAM,EAAEC,YAAYC,WAAWC,QAAQE,QAAQD,oBAAmB,IAChEJ;AAGF,MAAIK,WAAW,OAAO;AACpB,WAAO;EACT;AAGA,MAAID,qBAAqB;AACvB,WAAO;EACT;AAGA,MAAIH,eAAe,YAAY;AAC7B,WAAO;EACT;AAIA,MAAIC,cAAc,YAAYC,WAAW,OAAO;AAC9C,WAAO;EACT;AAEA,SAAO;AACT;","names":["getFinalExternals","getAllDeps","checkSwcHelpers","matchSwcTransformCondition","matchEs5PluginCondition","config","options","autoExternal","externals","appDirectory","deps","dependencies","peerDependencies","map","dep","RegExp","fs","json","JSON","parse","readFileSync","path","resolve","Object","keys","devDependencies","e","logger","warn","externalHelpers","swcHelpersPkgName","includes","local","Error","i18n","t","localeKeys","errors","condtionOptions","sourceType","buildType","format","disableSwcTransform","target"],"sources":["../../src/utils/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/utils/builder.ts"],"sourcesContent":["import path from 'path';\nimport { logger } from '@modern-js/utils/logger';\nimport type {\n BaseBuildConfig,\n ExternalHelpers,\n BuildType,\n Format,\n Target,\n} 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 devDependencies?: 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.devDependencies) {\n deps = [\n ...deps,\n ...Object.keys((json.devDependencies 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\nexport const checkSwcHelpers = async (options: {\n appDirectory: string;\n externalHelpers: ExternalHelpers;\n}) => {\n const { appDirectory, externalHelpers } = options;\n if (externalHelpers === false) {\n return;\n }\n const deps = await getAllDeps(appDirectory, {\n dependencies: true,\n devDependencies: true,\n });\n const swcHelpersPkgName = '@swc/helpers';\n if (!deps.includes(swcHelpersPkgName)) {\n const local = await import('../locale');\n throw new Error(local.i18n.t(local.localeKeys.errors.externalHelpers));\n }\n};\n\nexport const matchSwcTransformCondition = (condtionOptions: {\n sourceType: 'commonjs' | 'module';\n buildType: BuildType;\n format: Format;\n disableSwcTransform?: boolean;\n}) => {\n const { sourceType, buildType, format, disableSwcTransform } =\n condtionOptions;\n\n if (disableSwcTransform) {\n return false;\n }\n\n // 1. source code is esm\n // 2. bundleless\n // 3. bundle and format is esm\n\n if (sourceType === 'commonjs') {\n return false;\n }\n\n if (buildType === 'bundleless') {\n return true;\n }\n\n if (format === 'esm' || format === 'iife') {\n // when format is iife, swc-transform only transform syntax, esbuild transform js format.\n return true;\n }\n\n // bundle only use esbuild-transform in cjs format, because have some limitations\n // eg: treeshaking\n\n return false;\n};\n\nexport const matchEs5PluginCondition = (condtionOptions: {\n sourceType: 'commonjs' | 'module';\n buildType: BuildType;\n format: Format;\n target: Target;\n disableSwcTransform?: boolean;\n}) => {\n const { sourceType, buildType, format, target, disableSwcTransform } =\n condtionOptions;\n\n // dist is es5\n if (target !== 'es5') {\n return false;\n }\n\n // when use disbaleSwcTransform option, we must be use es5Plugin when target is es5\n if (disableSwcTransform) {\n return true;\n }\n\n // only use esbuild-transform, so need es5Plugin\n if (sourceType === 'commonjs') {\n return true;\n }\n\n // when source code is esm and dist is bundle + cjs, we can`t use swc-transform.\n // so we only use esbuild-transform and es5Plugin\n if (buildType === 'bundle' && format === 'cjs') {\n return true;\n }\n\n return false;\n};\n"]}
|
package/dist/utils/common.js
CHANGED
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "transformUndefineObject", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return transformUndefineObject;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const transformUndefineObject = (arr) => {
|
|
10
12
|
return arr.reduce((o, key) => {
|
package/dist/utils/common.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"mappings":";;;;+BAGaA
|
|
1
|
+
{"version":3,"mappings":";;;;+BAGaA;;;WAAAA;;;AAAN,MAAMA,0BAA0B,CACrCC,QAC8B;AAC9B,SAAOA,IAAIC,OAAO,CAACC,GAAGC,QAAQ;AAC5B,WAAO;MACL,GAAGD;MACH,CAACC,MAAMC;IACT;EACF,GAAG,CAAC;AACN;","names":["transformUndefineObject","arr","reduce","o","key","undefined"],"sources":["../../src/utils/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/utils/common.ts"],"sourcesContent":["/**\n * transform ['a', 'b'] to {a: undefined, b: undefined}\n */\nexport const transformUndefineObject = (\n arr: string[],\n): Record<string, undefined> => {\n return arr.reduce((o, key) => {\n return {\n ...o,\n [key]: undefined,\n };\n }, {});\n};\n"]}
|
package/dist/utils/config.js
CHANGED
|
@@ -10,11 +10,21 @@ function _export(target, all) {
|
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
_export(exports, {
|
|
13
|
-
validPartialBuildConfig: ()
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
validPartialBuildConfig: function() {
|
|
14
|
+
return validPartialBuildConfig;
|
|
15
|
+
},
|
|
16
|
+
validBuildTypeAndFormat: function() {
|
|
17
|
+
return validBuildTypeAndFormat;
|
|
18
|
+
},
|
|
19
|
+
mergeDefaultBaseConfig: function() {
|
|
20
|
+
return mergeDefaultBaseConfig;
|
|
21
|
+
},
|
|
22
|
+
getDtsConfig: function() {
|
|
23
|
+
return getDtsConfig;
|
|
24
|
+
},
|
|
25
|
+
isLegacyUserConfig: function() {
|
|
26
|
+
return isLegacyUserConfig;
|
|
27
|
+
}
|
|
18
28
|
});
|
|
19
29
|
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
20
30
|
const validPartialBuildConfig = (config) => {
|
package/dist/utils/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;;;;;;;;;EASaA,yBAAuB
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;EASaA,yBAAuB;WAAvBA;;EAUAC,yBAAuB;WAAvBA;;EAWAC,wBAAsB;WAAtBA;;EAyGAC,cAAY;WAAZA;;EAsBAC,oBAAkB;WAAlBA;;;;AApJN,MAAMJ,0BAA0B,CAACK,WAA+B;AACrE,MAAIC,MAAMC,QAAQF,SAAS;AACzB,eAAWG,KAAKH,QAAQ;AACtBJ,8BAAwBO;IAC1B;EACF,OAAO;AACLP,4BAAwBI;EAC1B;AACF;AAEO,MAAMJ,0BAA0B,CAACI,WAAmC;MAG9CA;AAF3B,MACEA,OAAOI,cAAc,gBACrB;IAAC;IAAQ;IAAOC,UAASL,wBAAOM,YAAM,QAAbN,6CAAiB,EAAE,GAC5C;AACA,UAAM,IAAIO,MACR,iGAAiG;EAErG;AACF;AAEO,MAAMV,yBAAyB,OACpCW,SACAC,YAC6B;MAkFjBD,gBACCA,iBAEPA,iBAEAA;AAtFN,QAAM,EAAEE,oBAAoBC,cAAa,IAAK,MAAM,iFAClD;AAEF,QAAM,EAAEC,UAAS,IAAK,MAAM,iFAAO;AACnC,QAAM,EAAEC,mBAAmBC,oBAAoBC,MAAK,IAAK,MAAM,iFAC7D;AAEF,QAAM,EAAEC,qBAAoB,IAAK,MAAM,iFAAO;AAC9C,QAAM,EAAEC,eAAc,IAAK,MAAM,iFAAO;AACxC,QAAMC,eAAe;IACnB,KAAKT,QAAQU;EACf;AACA,QAAMC,cAAcP,kBAAkBK,cAAcV,QAAQa,KAAK;AAOjE,QAAMA,QAAQC,OAAOC,KAAKH,aAAaI,OACrC,C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EpD,wDAAQgD,WAAK,QAAbhD,sDAAeoD,iBAAW,QAA1BpD,qEAA8BG,cAAc6C,MAAMI;IACtD;IACAC,UAAU;MACR,GAAGlD,cAAckD;MACjB,GAAGrD,QAAQqD;IACb;IACArB;IACAsB,kBAAiBtD,mCAAQsD,qBAAe,QAAvBtD,iEAA2BG,cAAcmD;IAC1DC,kBAAiBvD,mCAAQuD,qBAAe,QAAvBvD,iEAA2BG,cAAcoD;IAC1DC,aAAYxD,8BAAQwD,gBAAU,QAAlBxD,uDAAsBG,cAAcqD;IAChDC,sBACEzD,uCAAQyD,yBAAmB,QAA3BzD,yEAA+BG,cAAcsD;EACjD;AACF;AAEO,MAAMnE,eAAe,OAC1BoE,SACAC,eACG;AACH,QAAM,EAAEvD,WAAWwD,aAAaC,SAAQ,IAAK,MAAM,iFACjD;AAGF,MAAID,YAAYF,UAAU;AACxB,WAAOtD,UAAUuD;EACnB;AAEA,MAAIE,SAASH,UAAU;AACrB,WAAO;MACL,GAAGC;MACH,GAAGD;IACL;EACF;AAEA,SAAOA;AACT;AAEO,MAAMnE,qBAAqB,CAACC,WAEKsE,QAAQtE,OAAOuE,MAAM;","names":["validPartialBuildConfig","validBuildTypeAndFormat","mergeDefaultBaseConfig","getDtsConfig","isLegacyUserConfig","config","Array","isArray","c","buildType","includes","format","Error","pConfig","context","defaultBuildConfig","defaultConfig","cloneDeep","applyOptionsChain","ensureAbsolutePath","slash","getDefaultIndexEntry","getStyleConfig","defaultAlias","srcDirectory","mergedAlias","alias","Object","keys","reduce","prev","name","formattedValue","value","startsWith","appDirectory","styleConfig","sourceDir","metafile","input","userDefine","define","memo","JSON","stringify","esbuildOptions","asset","target","sourceMap","copy","outDir","dts","jsx","platform","splitting","minify","autoExternal","umdGlobals","umdModuleName","sideEffects","externals","style","inject","modules","autoModules","tailwindcss","redirect","externalHelpers","transformImport","sourceType","disableSwcTransform","userDTS","defaultDTS","isUndefined","isObject","Boolean","legacy"],"sources":["../../src/utils/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/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 const esbuildOptions = pConfig.esbuildOptions ?? defaultConfig.esbuildOptions;\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:\n pConfig.style?.tailwindcss ?? defaultConfig.style.tailwindcss,\n },\n redirect: {\n ...defaultConfig.redirect,\n ...pConfig.redirect,\n },\n esbuildOptions,\n externalHelpers: pConfig.externalHelpers ?? defaultConfig.externalHelpers,\n transformImport: pConfig.transformImport ?? defaultConfig.transformImport,\n sourceType: pConfig.sourceType ?? defaultConfig.sourceType,\n disableSwcTransform:\n pConfig.disableSwcTransform ?? defaultConfig.disableSwcTransform,\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/dist/utils/context.js
CHANGED
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "initModuleContext", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return initModuleContext;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
10
12
|
const initModuleContext = async (api) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;+BAGaA
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;+BAGaA;;;WAAAA;;;;AAAN,MAAMA,oBAAoB,OAAOC,QAAgC;AACtE,QAAM,EAAEC,aAAY,IAAK,MAAM,iFAAO;AACtC,QAAM,EAAEC,cAAcC,aAAY,IAAKH,IAAII,cAAa;AACxD,QAAMC,cAAcJ,aAAaC;AAEjC,SAAO;IAAEG;IAAaH;IAAcC;EAAa;AACnD;","names":["initModuleContext","api","isTypescript","appDirectory","srcDirectory","useAppContext","isTsProject"],"sources":["../../src/utils/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/utils/context.ts"],"sourcesContent":["import type { PluginAPI } from '@modern-js/core';\nimport type { ModuleTools } from '../types';\n\nexport const initModuleContext = async (api: PluginAPI<ModuleTools>) => {\n const { isTypescript } = await import('@modern-js/utils');\n const { appDirectory, srcDirectory } = api.useAppContext();\n const isTsProject = isTypescript(appDirectory);\n\n return { isTsProject, appDirectory, srcDirectory };\n};\n"]}
|
package/dist/utils/dts.js
CHANGED
|
@@ -10,11 +10,21 @@ function _export(target, all) {
|
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
_export(exports, {
|
|
13
|
-
generatorTsConfig: ()
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
generatorTsConfig: function() {
|
|
14
|
+
return generatorTsConfig;
|
|
15
|
+
},
|
|
16
|
+
getTscBinPath: function() {
|
|
17
|
+
return getTscBinPath;
|
|
18
|
+
},
|
|
19
|
+
resolveAlias: function() {
|
|
20
|
+
return resolveAlias;
|
|
21
|
+
},
|
|
22
|
+
assignTsConfigPath: function() {
|
|
23
|
+
return assignTsConfigPath;
|
|
24
|
+
},
|
|
25
|
+
printOrThrowDtsErrors: function() {
|
|
26
|
+
return printOrThrowDtsErrors;
|
|
27
|
+
}
|
|
18
28
|
});
|
|
19
29
|
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
20
30
|
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
package/dist/utils/dts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;;;;;;;;;EAUaA,mBAAiB
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;EAUaA,mBAAiB;WAAjBA;;EAmDAC,eAAa;WAAbA;;EA0BAC,cAAY;WAAZA;;EA6EAC,oBAAkB;WAAlBA;;EAuBAC,uBAAqB;WAArBA;;;;;iEA3LI;AAUV,MAAMJ,oBAAoB,OAC/BK,WACG;AACH,QAAM,EAAEC,IAAIC,OAAM,IAAK,MAAM,iFAAO;AACpC,QAAM,EAAEC,iBAAgB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AEL,MAAMM,WAAWC,MAAMf,IAAIG,YAAY;AAGxDE,aAAOD,MACL,IAAIG,iBAAiBH,OAAO;QAC1BK;MACF;IAEJ;EACF;AACF;","names":["generatorTsConfig","getTscBinPath","resolveAlias","assignTsConfigPath","printOrThrowDtsErrors","config","fs","nanoid","dtsTempDirectory","appDirectory","sourceDir","absSourceDir","tsconfigPath","tempDistAbsRootPath","path","join","tempDistAbsOurDir","relative","tempTsconfigPath","basename","ensureFileSync","extendsPath","dirname","resetConfig","extends","compilerOptions","declaration","emitDeclarationOnly","declarationDir","writeJSONSync","tempDistAbsSrcPath","default","findUp","exists","pathExists","tscBinFile","directory","targetFilePath","hasTscBinFile","undefined","cwd","existsSync","Error","options","watchFilenames","userTsconfig","globby","transformDtsAlias","distAbsPath","dtsDistPath","dtsFilenames","length","sync","absolute","result","filenames","baseUrl","paths","r","writeFileSync","content","copy","defaultTsConfigPath","tsconfig","dts","only","distPath","abortOnError","error","logger","chalk","InternalDTSError","local","buildType","warn","bgYellowBright","i18n","t","localeKeys","warns"],"sources":["../../src/utils/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/utils/dts.ts"],"sourcesContent":["import path from 'path';\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 // when `outDir` is './dist', `declarationDir` is `./types`\n // tsc will emit:\n // - ./dist/index.js\n // - ./types/index.d.ts\n // we only want to emit declarations\n declarationDir: 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(\n local.i18n.t(local.localeKeys.warns.dts.abortOnError),\n ),\n );\n logger.error(\n new InternalDTSError(error, {\n buildType,\n }),\n );\n }\n }\n};\n"]}
|
package/dist/utils/input.js
CHANGED
|
@@ -10,11 +10,21 @@ function _export(target, all) {
|
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
_export(exports, {
|
|
13
|
-
joinPathWithPrefix: ()
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
joinPathWithPrefix: function() {
|
|
14
|
+
return joinPathWithPrefix;
|
|
15
|
+
},
|
|
16
|
+
getAbsInput: function() {
|
|
17
|
+
return getAbsInput;
|
|
18
|
+
},
|
|
19
|
+
addInputToPreset: function() {
|
|
20
|
+
return addInputToPreset;
|
|
21
|
+
},
|
|
22
|
+
getDefaultIndexEntry: function() {
|
|
23
|
+
return getDefaultIndexEntry;
|
|
24
|
+
},
|
|
25
|
+
normalizeInput: function() {
|
|
26
|
+
return normalizeInput;
|
|
27
|
+
}
|
|
18
28
|
});
|
|
19
29
|
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
20
30
|
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
package/dist/utils/input.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;;;;;;;;;EAYaA,oBAAkB
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;EAYaA,oBAAkB;WAAlBA;;EAUAC,aAAW;WAAXA;;EAsBAC,kBAAgB;WAAhBA;;EAqBAC,sBAAoB;WAApBA;;EAyBAC,gBAAc;WAAdA;;;;;iEA1FI;AAYV,MAAMJ,qBACX,CAACK,SAAiB,CAACC,IAAYC,aAAqB;AAClD,QAAMC,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AKK,cAAc;AAC5B,MAAIkB,GAAGC,WAAWtB,QAAQ;AACxB,WAAO;MAAC,KAAKH,cAAK0B,SAASpB,cAAcH;;EAC3C;AAEAA,UAAQoB,cACJvB,cAAKC,KAAKK,cAAc,qBACxBN,cAAKC,KAAKK,cAAc;AAC5B,MAAIkB,GAAGC,WAAWtB,QAAQ;AACxB,WAAO;MAAC,KAAKH,cAAK0B,SAASpB,cAAcH;;EAC3C;AAEA,SAAO;AACT;AAEO,MAAMV,iBAAiB,OAC5BkC,YACAvB,YACG;AACH,MAAIuB,WAAWP,cAAc,gBAAgB,CAACO,WAAWN,OAAO;AAC9D,UAAM,EAAEhB,MAAK,IAAK,MAAM,iFAAO;AAC/B,WAAO;MAACA,MAAMsB,WAAWL,SAAS;;EACpC;AACA,SAAOhC,YAAYqC,WAAWN,OAAOjB;AACvC;","names":["joinPathWithPrefix","getAbsInput","addInputToPreset","getDefaultIndexEntry","normalizeInput","flag","p1","globPath","haveFlag","trim","startsWith","path","join","replace","entry","options","slash","appDirectory","resolvePathWithNoMatchFlag","Array","isArray","map","p","isAbsolute","newEntry","key","Object","keys","config","context","c","buildType","input","sourceDir","isTsProject","fs","existsSync","relative","baseConfig"],"sources":["../../src/utils/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/utils/input.ts"],"sourcesContent":["import path from 'path';\nimport { ModuleContext } from '../types';\nimport type {\n Input,\n BaseBuildConfig,\n PartialBuildConfig,\n} from '../types/config';\n\ninterface EntryOptions {\n appDirectory: string;\n}\n\nexport const joinPathWithPrefix =\n (flag: string) => (p1: string, globPath: string) => {\n const haveFlag = globPath.trim().startsWith(flag);\n if (haveFlag) {\n return path.join(flag, p1, globPath.replace(flag, ''));\n }\n\n return path.join(p1, globPath);\n };\n\nexport const getAbsInput = async (entry: Input, options: EntryOptions) => {\n const { slash } = await import('@modern-js/utils');\n const { appDirectory } = options;\n const resolvePathWithNoMatchFlag = joinPathWithPrefix('!');\n\n if (Array.isArray(entry)) {\n return entry.map(p =>\n path.isAbsolute(p)\n ? slash(p)\n : slash(resolvePathWithNoMatchFlag(appDirectory, p)),\n );\n }\n\n const newEntry: Record<string, string> = {};\n for (const key of Object.keys(entry)) {\n newEntry[key] = path.isAbsolute(entry[key])\n ? slash(entry[key])\n : slash(resolvePathWithNoMatchFlag(appDirectory, entry[key]));\n }\n return newEntry;\n};\n\nexport const addInputToPreset = async (\n config: PartialBuildConfig,\n context: ModuleContext,\n) => {\n if (Array.isArray(config)) {\n for (const c of config) {\n if (c.buildType === 'bundle') {\n c.input = await getDefaultIndexEntry(context);\n } else if (c.buildType === 'bundleless') {\n c.sourceDir = './src';\n }\n }\n } else if (config.buildType === 'bundle') {\n config.input = await getDefaultIndexEntry(context);\n } else if (config.buildType === 'bundleless') {\n config.sourceDir = './src';\n }\n\n return config;\n};\n\nexport const getDefaultIndexEntry = async ({\n isTsProject,\n appDirectory,\n}: {\n isTsProject: boolean;\n appDirectory: string;\n}) => {\n const { fs } = await import('@modern-js/utils');\n let entry = isTsProject\n ? path.join(appDirectory, './src/index.ts')\n : path.join(appDirectory, './src/index.js');\n if (fs.existsSync(entry)) {\n return [`./${path.relative(appDirectory, entry)}`];\n }\n\n entry = isTsProject\n ? path.join(appDirectory, './src/index.tsx')\n : path.join(appDirectory, './src/index.jsx');\n if (fs.existsSync(entry)) {\n return [`./${path.relative(appDirectory, entry)}`];\n }\n\n return [];\n};\n\nexport const normalizeInput = async (\n baseConfig: BaseBuildConfig,\n options: EntryOptions,\n) => {\n if (baseConfig.buildType === 'bundleless' && !baseConfig.input) {\n const { slash } = await import('@modern-js/utils');\n return [slash(baseConfig.sourceDir)];\n }\n return getAbsInput(baseConfig.input, options);\n};\n"]}
|
package/dist/utils/language.js
CHANGED
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "initLocalLanguage", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return initLocalLanguage;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
10
12
|
const initLocalLanguage = async () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;+BAAaA
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;+BAAaA;;;WAAAA;;;;AAAN,MAAMA,oBAAoB,YAAY;AAC3C,QAAMC,QAAQ,MAAM,iFAAO;AAC3B,QAAM,EAAEC,kBAAiB,IAAK,MAAM,iFAClC;AAEF,QAAMC,SAASD;AACfD,QAAMG,KAAKC,eAAe;IAAEF;EAAO;AACnC,SAAOF;AACT;","names":["initLocalLanguage","local","getLocaleLanguage","locale","i18n","changeLanguage"],"sources":["../../src/utils/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/utils/language.ts"],"sourcesContent":["export const initLocalLanguage = async () => {\n const local = await import('../locale');\n const { getLocaleLanguage } = await import(\n '@modern-js/plugin-i18n/language-detector'\n );\n const locale = getLocaleLanguage();\n local.i18n.changeLanguage({ locale });\n return local;\n};\n"]}
|
|
@@ -10,8 +10,12 @@ function _export(target, all) {
|
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
_export(exports, {
|
|
13
|
-
watchPlugin: ()
|
|
14
|
-
|
|
13
|
+
watchPlugin: function() {
|
|
14
|
+
return watchPlugin;
|
|
15
|
+
},
|
|
16
|
+
externalPlugin: function() {
|
|
17
|
+
return externalPlugin;
|
|
18
|
+
}
|
|
15
19
|
});
|
|
16
20
|
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
17
21
|
const _logger = require("@modern-js/utils/logger");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;;;;;;;;;EAIaA,aAAW
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;EAIaA,aAAW;WAAXA;;EAuBAC,gBAAc;WAAdA;;;;wBA3BU;AAIhB,MAAMD,cAAc,CACzBE,KACAC,WACkB;AAClB,SAAO;IACLC,MAAM;IACNC,MAAMC,UAAU;AACdA,eAASC,MAAMC,YAAYC,IAAI,gBAAgB,YAAY;AACzD,cAAM,EAAEC,kBAAiB,IAAK,MAAM,iFAAO;AAC3C,cAAM,EAAEC,mBAAkB,IAAK,MAAM,iFAAO;AAC5C,cAAMC,YAAY,IAChBT,OAAOU,cAAc,WAAW,WAAW,gBACzCV,OAAOW,UAAUX,OAAOY;AAE5BC,uBAAOC,KAAK,MAAMP,kBAAkBE,WAAWD,mBAAmBO,GAAG;AAErE,cAAMC,SAASjB,IAAIkB,eAAc;AACjCD,eAAOE,aAAa;UAAEC,aAAanB;QAAO;MAC5C;IACF;EACF;AACF;AAEO,MAAMF,iBAAiB,CAC5BE,QACAoB,YACkB;AAClB,SAAO;IACLnB,MAAM;IACNC,MAAMC,UAAU;AACdA,eAASC,MAAMiB,WAAWC,WAAW,mBAAmB,YAAY;AAClE,cAAM,EAAEC,kBAAiB,IAAK,MAAM,iFAAO;AAC3C,cAAMC,iBAAiB,MAAMD,kBAAkBvB,QAAQoB;AACvDjB,iBAASH,OAAOyB,WAAWD;MAC7B;IACF;EACF;AACF;","names":["watchPlugin","externalPlugin","api","config","name","apply","compiler","hooks","watchChange","tap","watchSectionTitle","SectionTitleStatus","titleText","buildType","format","target","logger","info","Log","runner","useHookRunners","buildWatchJs","buildConfig","options","initialize","tapPromise","getFinalExternals","finalExternals","external"],"sources":["../../src/utils/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/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
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "watchSectionTitle", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return watchSectionTitle;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
10
12
|
const _log = require("../constants/log");
|
package/dist/utils/log.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;+BAEaA
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;+BAEaA;;;WAAAA;;;;qBAFsB;AAE5B,MAAMA,oBAAoB,OAC/BC,KACAC,QACAC,cACG;AACH,QAAM,EAAEC,MAAK,IAAK,MAAM,iFAAO;AAC/B,MAAIF,WAAWG,wBAAmBC,SAAS;AACzC,WAAO,GAAGF,MAAMG,KAAKN,QAAQG,MAAMI,MAAM;EAC3C,WAAWN,WAAWG,wBAAmBI,MAAM;AAC7C,WAAO,GAAGL,MAAMG,KAAKN,QAAQG,MAAMM,IAAI;EACzC;AAEA,SAAO,GAAGN,MAAMG,KAAKN,QAAQE,YAAYA,YAAY;AACvD;","names":["watchSectionTitle","str","status","detailLog","chalk","SectionTitleStatus","Success","gray","green","Fail","red"],"sources":["../../src/utils/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/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"]}
|
package/dist/utils/onExit.js
CHANGED
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "addExitListener", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return addExitListener;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
10
12
|
const addExitListener = async (fn) => {
|
package/dist/utils/onExit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;+BAAaA
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;+BAAaA;;;WAAAA;;;;AAAN,MAAMA,kBAAkB,OAAOC,OAA4B;AAChE,QAAM,EAAEC,SAASC,OAAM,IAAK,MAAM,iFAAO;AAEzCA,SAAO,OAAMC,SAAQ;AACnB,QAAIA,SAAS,GAAG;AACd;IACF;AAEA,UAAMH;EACR;AACF;","names":["addExitListener","fn","default","onExit","code"],"sources":["../../src/utils/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/utils/onExit.ts"],"sourcesContent":["export const addExitListener = async (fn: () => Promise<void>) => {\n const { default: onExit } = await import('../../compiled/signal-exit');\n\n onExit(async code => {\n if (code === 0) {\n return;\n }\n\n await fn();\n });\n};\n"]}
|
package/dist/utils/path.js
CHANGED
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "getCompiledPath", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return getCompiledPath;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
10
12
|
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
package/dist/utils/path.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;+BAEaA
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;+BAEaA;;;WAAAA;;;;;iEAFI;AAEV,MAAMA,kBAAkB,OAAOC,gBAAwB;AAC5D,QAAM,EAAEC,MAAK,IAAK,MAAM,iFAAO;AAC/B,SAAOA,MAAMC,cAAKC,KAAKC,WAAW,kBAAkBJ;AACtD;","names":["getCompiledPath","packageName","slash","path","join","__dirname"],"sources":["../../src/utils/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/utils/path.ts"],"sourcesContent":["import path from 'path';\n\nexport const getCompiledPath = async (packageName: string) => {\n const { slash } = await import('@modern-js/utils');\n return slash(path.join(__dirname, '../../compiled', packageName));\n};\n"]}
|
package/dist/utils/print.js
CHANGED
|
@@ -10,13 +10,27 @@ function _export(target, all) {
|
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
_export(exports, {
|
|
13
|
-
bundleFiles: ()
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
bundleFiles: function() {
|
|
14
|
+
return bundleFiles;
|
|
15
|
+
},
|
|
16
|
+
bundlelessFiles: function() {
|
|
17
|
+
return bundlelessFiles;
|
|
18
|
+
},
|
|
19
|
+
addOutputChunk: function() {
|
|
20
|
+
return addOutputChunk;
|
|
21
|
+
},
|
|
22
|
+
addRollupChunk: function() {
|
|
23
|
+
return addRollupChunk;
|
|
24
|
+
},
|
|
25
|
+
addDtsFiles: function() {
|
|
26
|
+
return addDtsFiles;
|
|
27
|
+
},
|
|
28
|
+
printFileSize: function() {
|
|
29
|
+
return printFileSize;
|
|
30
|
+
},
|
|
31
|
+
printSucceed: function() {
|
|
32
|
+
return printSucceed;
|
|
33
|
+
}
|
|
20
34
|
});
|
|
21
35
|
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
22
36
|
const _path = require("path");
|
package/dist/utils/print.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;;;;;;;;;EAkBaA,aAAW
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;EAkBaA,aAAW;WAAXA;;EAEAC,iBAAe;WAAfA;;EAEAC,gBAAc;WAAdA;;EAmBAC,gBAAc;WAAdA;;EAiBAC,aAAW;WAAXA;;EAeAC,eAAa;WAAbA;;EAKAC,cAAY;WAAZA;;;;sBA9EqB;uBAEJ;qBASvB;AAOA,MAAMN,cAAuB;AAE7B,MAAMC,kBAA2B;AAEjC,MAAMC,iBAAiB,CAC5BK,aACAC,cACAC,aACG;AACH,QAAMC,QAAQC,MAAMC,KAAKL,aAAaM,IAAIC,SAAO;AAC/C,UAAM,CAACC,MAAMC,SAASF;AACtB,WAAO;MACLG,OAAMC,mBAASV,cAAcO;MAC7BI,MAAMH,MAAMI,SAASC;IACvB;EACF;AACA,MAAIZ,UAAU;AACZT,gBAAYsB,KAAI,GAAIZ;EACtB,OAAO;AACLT,oBAAgBqB,KAAI,GAAIZ;EAC1B;AACF;AAEO,MAAMP,iBAAiB,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,GAC3CmC,yBAAoBnC,MAAM;AAG5BmB,gBAAOC,KAAK,oBAAoBzC,YAAYqB;CAAgB;AAE5D,QAAMoC,YACJD,2BACA,IAAIE,OAAON,oBAAoB,MAC/BO;AACFnB,gBAAOS,IAAIX,aAAMsB,KAAKtB,aAAMuB,MAAMJ;AAElCzD,cAAY8D,QAAQ,CAAC,EAAE7C,MAAME,KAAI,MAAO;AACtC,UAAM4C,UAAU,GAAG9C,OAAO,IAAIyC,OAC5BN,oBAAoBnC,KAAKI,SAAS,KAChCsB,YAAYxB;AAChBqB,kBAAOS,IAAIc;EACb;AACF;AAEA,MAAM7B,sBAAsB,MAAM;AAChC,MAAIjC,gBAAgBoB,WAAW,GAAG;AAChC;EACF;AAEA,QAAM2C,QAAQ/D,gBAAgBoB;AAC9B,QAAM4C,YAAYhE,gBAAgBoD,OAAO,CAACa,OAAOjC,SAAS;AACxD,WAAOiC,QAAQjC,KAAKd;EACtB,GAAG;AACH,QAAMsB,OAAO,wBAAwBuB,kCAAkC1B,aAAMC,KAC3EI,YAAYsB;AAEdzB,gBAAOC,KAAKA;AACd;","names":["bundleFiles","bundlelessFiles","addOutputChunk","addRollupChunk","addDtsFiles","printFileSize","printSucceed","outputChunk","appDirectory","isBundle","files","Array","from","map","val","path","chunk","name","relative","size","contents","length","push","rollupOutput","distDir","output","o","resolve","fileName","code","fastGlob","slash","stats","file","printBundlelessInfo","printBundleFiles","totalDuration","time","chalk","cyan","logger","info","buildSuccessText","prettyBytes","bytes","unit","exp","Math","floor","log","pow","toFixed","longestFileLength","reduce","max","str","reportFile1LineText","headerRow","repeat","reportFile2LineText","bold","green","forEach","infoRow","count","totalSize","total"],"sources":["../../src/utils/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/utils/print.ts"],"sourcesContent":["import { relative, resolve } from 'path';\nimport type { ILibuilder } from '@modern-js/libuild';\nimport { chalk, logger } from '@modern-js/utils';\nimport type {\n RollupOutput,\n OutputChunk,\n} from '../../compiled/rollup/types/rollup';\nimport {\n buildSuccessText,\n reportFile1LineText,\n reportFile2LineText,\n} from '../constants/log';\n\ntype Files = {\n name: string;\n size: number;\n};\n\nexport const bundleFiles: Files[] = [];\n\nexport const bundlelessFiles: Files[] = [];\n\nexport const addOutputChunk = (\n outputChunk: ILibuilder['outputChunk'],\n appDirectory: string,\n isBundle: boolean,\n) => {\n const files = Array.from(outputChunk).map(val => {\n const [path, chunk] = val;\n return {\n name: relative(appDirectory, path),\n size: chunk.contents.length,\n };\n });\n if (isBundle) {\n bundleFiles.push(...files);\n } else {\n bundlelessFiles.push(...files);\n }\n};\n\nexport const addRollupChunk = (\n rollupOutput: RollupOutput,\n appDirectory: string,\n distDir: string,\n) => {\n const { output } = rollupOutput;\n bundleFiles.push(\n ...output.map(o => {\n return {\n name: relative(appDirectory, resolve(distDir, o.fileName)),\n // only d.ts, is outputChunk not outputAsset\n size: (o as OutputChunk).code.length,\n };\n }),\n );\n};\n\nexport const addDtsFiles = async (distDir: string, appDirectory: string) => {\n const { fastGlob, slash } = await import('@modern-js/utils');\n const files = await fastGlob(`${slash(distDir)}**/*.d.ts`, {\n stats: true,\n });\n bundlelessFiles.push(\n ...files.map(file => {\n return {\n name: relative(appDirectory, file.path),\n size: file.stats.size,\n };\n }),\n );\n};\n\nexport const printFileSize = () => {\n printBundlelessInfo();\n printBundleFiles();\n};\n\nexport const printSucceed = (totalDuration: number) => {\n const time = chalk.cyan(`${totalDuration / 1000}s`);\n logger.info(`${buildSuccessText} in ${time}`);\n};\n\nconst prettyBytes = (bytes: number) => {\n if (bytes === 0) {\n return '0 B';\n }\n const unit = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];\n const exp = Math.floor(Math.log(bytes) / Math.log(1024));\n return `${(bytes / Math.pow(1024, exp)).toFixed(2)} ${unit[exp]}`;\n};\n\nconst printBundleFiles = () => {\n if (bundleFiles.length === 0) {\n return;\n }\n const longestFileLength = bundleFiles.reduce(\n (max, str) => Math.max(max, str.name.length),\n reportFile1LineText.length,\n );\n\n logger.info(`Bundle generated ${bundleFiles.length} files\\n`);\n\n const headerRow =\n reportFile1LineText +\n ' '.repeat(longestFileLength - 10) +\n reportFile2LineText;\n logger.log(chalk.bold(chalk.green(headerRow)));\n\n bundleFiles.forEach(({ name, size }) => {\n const infoRow = `${name}${' '.repeat(\n longestFileLength - name.length + 2,\n )}${prettyBytes(size)}`;\n logger.log(infoRow);\n });\n};\n\nconst printBundlelessInfo = () => {\n if (bundlelessFiles.length === 0) {\n return;\n }\n\n const count = bundlelessFiles.length;\n const totalSize = bundlelessFiles.reduce((total, file) => {\n return total + file.size;\n }, 0);\n const info = `Bundleless generated ${count} files, the total size is ${chalk.cyan(\n prettyBytes(totalSize),\n )}`;\n logger.info(info);\n};\n"]}
|
package/dist/utils/style.js
CHANGED
|
@@ -10,10 +10,18 @@ function _export(target, all) {
|
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
_export(exports, {
|
|
13
|
-
getLessConfig: ()
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
getLessConfig: function() {
|
|
14
|
+
return getLessConfig;
|
|
15
|
+
},
|
|
16
|
+
getSassConfig: function() {
|
|
17
|
+
return getSassConfig;
|
|
18
|
+
},
|
|
19
|
+
getPostcssConfig: function() {
|
|
20
|
+
return getPostcssConfig;
|
|
21
|
+
},
|
|
22
|
+
getStyleConfig: function() {
|
|
23
|
+
return getStyleConfig;
|
|
24
|
+
}
|
|
17
25
|
});
|
|
18
26
|
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
19
27
|
const getLessConfig = async (config) => {
|
package/dist/utils/style.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"mappings":";;;;;;;;;;;;EASaA,eAAa
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;EASaA,eAAa;WAAbA;;EAeAC,eAAa;WAAbA;;EAcAC,kBAAgB;WAAhBA;;EA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AQO,WAAK,QAAbP,kDAAeqB,YAAW,CAAC,GAC3BV;AAEF,MAAID,aAAaY,QAAQ;AACvBL,iBAAaJ,QAASG,KAAI,GAAIN;EAChC;AAEA,SAAOO;AACT;AAEO,MAAMlB,iBAAiB,OAAOC,WAAmC;AACtE,QAAMuB,gBAAgB,MAAMzB,iBAAiBE;AAC7C,QAAMwB,aAAa,MAAM5B,cAAcI;AACvC,QAAMyB,aAAa,MAAM5B,cAAcG;AACvC,SAAO;IACLQ,MAAMgB;IACNf,MAAMgB;IACNJ,SAASE;EACX;AACF;","names":["getLessConfig","getSassConfig","getPostcssConfig","getStyleConfig","config","applyOptionsChain","getCompiledPath","mergedOptions","lessOptions","javascriptEnabled","implementation","style","less","sass","extraPlugins","utils","addPlugins","plugins","Array","isArray","push","mergedConfig","require","filter","Boolean","postcss","length","postcssConfig","lessConfig","sassConfig"],"sources":["../../src/utils/home/runner/work/modern.js/modern.js/packages/solutions/module-tools/src/utils/style.ts"],"sourcesContent":["import type { AcceptedPlugin } from 'postcss';\nimport type { PostcssOptions } from '@modern-js/libuild';\nimport type {\n PartialBaseBuildConfig,\n PostCSSConfigUtils,\n LessOptions,\n SassOptions,\n} from '../types';\n\nexport const getLessConfig = async (config: PartialBaseBuildConfig) => {\n const { applyOptionsChain } = await import('@modern-js/utils');\n const { getCompiledPath } = await import('./path');\n\n const mergedOptions = applyOptionsChain<LessOptions, never>(\n {\n lessOptions: { javascriptEnabled: true },\n implementation: await getCompiledPath('less'),\n },\n config?.style?.less || {},\n );\n\n return mergedOptions;\n};\n\nexport const getSassConfig = async (config: PartialBaseBuildConfig) => {\n const { applyOptionsChain } = await import('@modern-js/utils');\n const { getCompiledPath } = await import('./path');\n\n const mergedOptions = applyOptionsChain<SassOptions, never>(\n {\n implementation: await getCompiledPath('sass'),\n },\n config?.style?.sass || {},\n );\n\n return mergedOptions;\n};\n\nexport const getPostcssConfig = async (config: PartialBaseBuildConfig) => {\n const { applyOptionsChain } = await import('@modern-js/utils');\n const { getCompiledPath } = await import('./path');\n const extraPlugins: AcceptedPlugin[] = [];\n\n const utils = {\n addPlugins(plugins: AcceptedPlugin | AcceptedPlugin[]) {\n if (Array.isArray(plugins)) {\n extraPlugins.push(...plugins);\n } else {\n extraPlugins.push(plugins);\n }\n },\n };\n\n const mergedConfig = applyOptionsChain<\n PostcssOptions & { $$tools?: string },\n PostCSSConfigUtils\n >(\n {\n // TODO: when schema support redefine\n // $$tools: 'module-tools',\n plugins: [\n require(await getCompiledPath('postcss-flexbugs-fixes')),\n require(await getCompiledPath('postcss-custom-properties')),\n require(await getCompiledPath('postcss-initial')),\n require(await getCompiledPath('postcss-page-break')),\n require(await getCompiledPath('postcss-font-variant')),\n require(await getCompiledPath('postcss-media-minmax')),\n require(await getCompiledPath('postcss-nesting')),\n ].filter(Boolean),\n },\n config?.style?.postcss || {},\n utils,\n );\n if (extraPlugins.length) {\n mergedConfig.plugins!.push(...extraPlugins);\n }\n\n return mergedConfig;\n};\n\nexport const getStyleConfig = async (config: PartialBaseBuildConfig) => {\n const postcssConfig = await getPostcssConfig(config);\n const lessConfig = await getLessConfig(config);\n const sassConfig = await getSassConfig(config);\n return {\n less: lessConfig,\n sass: sassConfig,\n postcss: postcssConfig,\n };\n};\n"]}
|
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "transformDtsAlias", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return transformDtsAlias;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
10
12
|
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|