@modern-js/module-tools 2.5.2-beta.3 → 2.6.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/CHANGELOG.md +29 -0
- package/compiled/rollup-plugin-dts/dist/rollup-plugin-dts.d.ts +106 -3
- package/compiled/rollup-plugin-dts/package.json +1 -1
- package/dist/build.js +6 -0
- package/dist/build.js.map +1 -0
- package/dist/builder/build.js +7 -0
- package/dist/builder/build.js.map +1 -0
- package/dist/builder/clear.js +6 -0
- package/dist/builder/clear.js.map +1 -0
- package/dist/builder/copy.js +20 -11
- package/dist/builder/copy.js.map +1 -0
- package/dist/builder/dts/index.js +2 -0
- package/dist/builder/dts/index.js.map +1 -0
- package/dist/builder/dts/rollup.js +19 -1
- package/dist/builder/dts/rollup.js.map +1 -0
- package/dist/builder/dts/tsc.js +8 -0
- package/dist/builder/dts/tsc.js.map +1 -0
- package/dist/builder/index.js +6 -0
- package/dist/builder/index.js.map +1 -0
- package/dist/builder/platform.js +6 -0
- package/dist/builder/platform.js.map +1 -0
- package/dist/cli.js +6 -0
- package/dist/cli.js.map +1 -0
- package/dist/command.js +6 -0
- package/dist/command.js.map +1 -0
- package/dist/config/defineConfig.js +2 -0
- package/dist/config/defineConfig.js.map +1 -0
- package/dist/config/legacy-schema.js +9 -0
- package/dist/config/legacy-schema.js.map +1 -0
- package/dist/config/normalize.js +6 -0
- package/dist/config/normalize.js.map +1 -0
- package/dist/config/schema.js +4 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/config/transform-legacy-config.js +6 -0
- package/dist/config/transform-legacy-config.js.map +1 -0
- package/dist/constants/build-presets.js +2 -0
- package/dist/constants/build-presets.js.map +1 -0
- package/dist/constants/build.js +2 -0
- package/dist/constants/build.js.map +1 -0
- package/dist/constants/colors.js +2 -0
- package/dist/constants/colors.js.map +1 -0
- package/dist/constants/dts.js +4 -0
- package/dist/constants/dts.js.map +1 -0
- package/dist/constants/file.js +2 -0
- package/dist/constants/file.js.map +1 -0
- package/dist/constants/legacy-build-presets.js +6 -0
- package/dist/constants/legacy-build-presets.js.map +1 -0
- package/dist/constants/log.js +2 -0
- package/dist/constants/log.js.map +1 -0
- package/dist/dev.js +6 -0
- package/dist/dev.js.map +1 -0
- package/dist/error.js +2 -0
- package/dist/error.js.map +1 -0
- package/dist/hooks/build.js +2 -0
- package/dist/hooks/build.js.map +1 -0
- package/dist/hooks/dev.js +3 -0
- package/dist/hooks/dev.js.map +1 -0
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/misc.js +2 -0
- package/dist/hooks/misc.js.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/locale/en.js +2 -0
- package/dist/locale/en.js.map +1 -0
- package/dist/locale/index.js +2 -0
- package/dist/locale/index.js.map +1 -0
- package/dist/locale/zh.js +2 -0
- package/dist/locale/zh.js.map +1 -0
- package/dist/plugins.js +6 -0
- package/dist/plugins.js.map +1 -0
- package/dist/types/color.js +2 -0
- package/dist/types/color.js.map +1 -0
- package/dist/types/command.js +2 -0
- package/dist/types/command.js.map +1 -0
- package/dist/types/config/index.js +2 -0
- package/dist/types/config/index.js.map +1 -0
- package/dist/types/config/style.js +2 -0
- package/dist/types/config/style.js.map +1 -0
- package/dist/types/context.js +2 -0
- package/dist/types/context.js.map +1 -0
- package/dist/types/copy.js +2 -0
- package/dist/types/copy.js.map +1 -0
- package/dist/types/dts.js +2 -0
- package/dist/types/dts.js.map +1 -0
- package/dist/types/hooks.js +2 -0
- package/dist/types/hooks.js.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/legacyConfig/index.js +2 -0
- package/dist/types/legacyConfig/index.js.map +1 -0
- package/dist/types/legacyConfig/output.js +2 -0
- package/dist/types/legacyConfig/output.js.map +1 -0
- package/dist/types/legacyConfig/source.js +2 -0
- package/dist/types/legacyConfig/source.js.map +1 -0
- package/dist/types/legacyConfig/tools.js +2 -0
- package/dist/types/legacyConfig/tools.js.map +1 -0
- package/dist/types/utils.js +2 -0
- package/dist/types/utils.js.map +1 -0
- package/dist/utils/builder.js +6 -0
- package/dist/utils/builder.js.map +1 -0
- package/dist/utils/config.js +6 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/context.js +6 -0
- package/dist/utils/context.js.map +1 -0
- package/dist/utils/dts.js +7 -0
- package/dist/utils/dts.js.map +1 -0
- package/dist/utils/input.js +6 -0
- package/dist/utils/input.js.map +1 -0
- package/dist/utils/language.js +6 -0
- package/dist/utils/language.js.map +1 -0
- package/dist/utils/libuild-plugins.js +6 -0
- package/dist/utils/libuild-plugins.js.map +1 -0
- package/dist/utils/log.js +6 -0
- package/dist/utils/log.js.map +1 -0
- package/dist/utils/onExit.js +6 -0
- package/dist/utils/onExit.js.map +1 -0
- package/dist/utils/path.js +6 -0
- package/dist/utils/path.js.map +1 -0
- package/dist/utils/print.js +7 -0
- package/dist/utils/print.js.map +1 -0
- package/dist/utils/style.js +8 -0
- package/dist/utils/style.js.map +1 -0
- package/dist/utils/tspaths-transform.js +9 -0
- package/dist/utils/tspaths-transform.js.map +1 -0
- package/package.json +17 -17
|
@@ -0,0 +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' | 'sideEffects'\n> & {\n sideEffects: LibuildUserConfig['sideEffects'];\n dts: false | DTSOptions;\n style: Omit<Required<LibuildStyle>, 'cleanCss'> & {\n tailwindCss: TailwindCSSConfig;\n };\n alias: Record<string, string>;\n};\n\nexport type PartialBaseBuildConfig = {\n buildType?: 'bundleless' | 'bundle';\n format?: Format;\n target?: Target;\n dts?: DTS;\n sourceMap?: SourceMap;\n sourceDir?: string;\n copy?: CopyConfig;\n asset?: Asset;\n jsx?: JSX;\n outDir?: string;\n alias?: AliasOption;\n input?: Input;\n metafile?: boolean;\n platform?: LibuildUserConfig['platform'];\n splitting?: LibuildUserConfig['splitting'];\n minify?: LibuildUserConfig['minify'];\n externals?: LibuildUserConfig['external'];\n autoExternal?: AutoExternal;\n umdGlobals?: LibuildUserConfig['globals'];\n umdModuleName?: ((chunkName: string) => string) | string | undefined;\n define?: LibuildUserConfig['define'];\n style?: StyleConfig;\n sideEffects?: LibuildUserConfig['sideEffects'];\n};\n\nexport type BuildConfig = BaseBuildConfig | BaseBuildConfig[];\nexport type PartialBuildConfig =\n | PartialBaseBuildConfig\n | PartialBaseBuildConfig[];\n\nexport type BuildPreset =\n | keyof typeof presetList\n | ((options: {\n preset: typeof BuildInPreset;\n extendPreset: (\n extendPresetName: keyof typeof BuildInPreset,\n extendBuildConfig: PartialBaseBuildConfig,\n ) => PartialBuildConfig;\n }) => PartialBuildConfig | Promise<PartialBuildConfig>);\n\nexport interface StyleConfig {\n less?: LessConfig;\n sass?: SassConfig;\n postcss?: PostCSSConfig;\n autoModules?: LibuildStyle['autoModules'];\n modules?: LibuildStyle['modules'];\n inject?: LibuildStyle['inject'];\n /**\n * The configuration of `tools.tailwindcss` is provided by `tailwindcss` plugin.\n * Please use `yarn new` or `pnpm new` to enable the corresponding capability.\n * @requires `tailwindcss` plugin\n */\n tailwindcss?: TailwindCSSConfig;\n}\n\nexport interface StorybookBuildConfig {\n webpack?: WebpackBuilderToolsConfig['webpack'];\n webpackChain?: WebpackBuilderToolsConfig['webpackChain'];\n}\nexport interface Dev {\n storybook?: StorybookBuildConfig;\n}\n\nexport interface RuntimeUserConfig {\n [name: string]: any;\n}\n\nexport interface ModuleExtraConfig {\n designSystem?: Record<string, any>;\n\n buildConfig?: PartialBuildConfig;\n\n buildPreset?: BuildPreset;\n\n dev?: Dev;\n\n runtime?: RuntimeUserConfig;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"mappings":";;;;;;;;;;;;;AAAA;AAAA;","names":[],"sources":["../../../src/types/config/style.ts"],"sourcesContent":["import type { Style } from '@modern-js/libuild';\nimport type { AcceptedPlugin as PostCSSPlugin } from 'postcss';\n\nexport type LessOptions = Required<Style>['less'];\nexport type SassOptions = Required<Style>['sass'];\nexport type PostcssOptions = Required<Style>['postcss'];\n\nexport type LessConfig =\n | LessOptions\n | ((options: LessOptions) => LessOptions | void);\n\nexport type SassConfig =\n | SassOptions\n | ((options: SassOptions) => SassOptions | void);\n\nexport type PostCSSConfigUtils = {\n addPlugins: (plugins: PostCSSPlugin | PostCSSPlugin[]) => void;\n};\nexport type PostCSSConfig =\n | PostcssOptions\n | ((\n options: PostcssOptions,\n utils: PostCSSConfigUtils,\n ) => PostcssOptions | void);\n\nexport type TailwindCSSConfig =\n | Record<string, any>\n | ((options: Record<string, any>) => Record<string, any> | void);\n"]}
|
package/dist/types/context.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"mappings":";;;;;;;;;;;;;AAAA;AAAA;","names":[],"sources":["../../src/types/context.ts"],"sourcesContent":["export interface ModuleContext {\n isTsProject: boolean;\n appDirectory: string;\n srcDirectory: string;\n}\n"]}
|
package/dist/types/copy.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"mappings":";;;;;;;;;;;;;AAAA;AAAA;","names":[],"sources":["../../src/types/copy.ts"],"sourcesContent":["import type { globby } from '@modern-js/utils';\n\nexport interface CopyPattern {\n from: string;\n to?: string;\n context?: string;\n globOptions?: globby.GlobbyOptions;\n}\n\nexport interface CopyOptions {\n patterns?: CopyPattern[];\n options?: {\n concurrency?: number;\n enableCopySync?: boolean;\n };\n}\n\nexport type CopyConfig = CopyOptions;\n"]}
|
package/dist/types/dts.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"mappings":";;;;;;;;;;;;;AAAA;AAAA;","names":[],"sources":["../../src/types/dts.ts"],"sourcesContent":["import type { AliasOption } from './config';\n\nexport interface BundlelessGeneratorDtsConfig {\n appDirectory: string;\n distAbsPath: string;\n tsconfigPath: string;\n watch: boolean;\n sourceDir: string;\n alias: AliasOption;\n}\n\nexport interface ITsconfig {\n compilerOptions?:\n | {\n rootDir?: string;\n baseUrl?: string;\n declaration?: boolean;\n emitDeclarationOnly?: boolean;\n emitDecoratorMetadata?: boolean;\n isolatedModules?: boolean;\n allowJs?: boolean;\n outDir?: string;\n paths?: Record<string, string[]>;\n }\n | undefined;\n include?: string[];\n exclude?: string[];\n extends?: string;\n}\n"]}
|
package/dist/types/hooks.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"mappings":";;;;;;;;;;;;;AAAA;AAAA;","names":[],"sources":["../../src/types/hooks.ts"],"sourcesContent":["import { DevToolData as BaseDevToolData } from '@modern-js/core';\nimport { registerHook } from '../hooks';\nimport type { BaseBuildConfig, BuildConfig, BuildType } from './config';\nimport type { DevCommandOptions, BuildCommandOptions } from './command';\n\nexport interface BuildTaskResult {\n status: 'success' | 'fail';\n message?: string;\n config: BaseBuildConfig;\n}\n\nexport interface BuildResult {\n status: 'success' | 'fail';\n message?: string;\n config: BuildConfig;\n commandOptions: BuildCommandOptions;\n totalDuration: number;\n}\nexport interface BuildPlatformResult {\n status: 'success' | 'fail';\n message: string | Error | null;\n}\n\nexport type DevToolData = BaseDevToolData<DevCommandOptions>;\n\nexport type PromptResult = { choiceDevTool: string } & Record<string, any>;\n\nexport type ModuleToolsHooks = typeof registerHook;\n\nexport interface WatchJsHookContext {\n buildConfig: BaseBuildConfig;\n}\n\nexport interface WatchDtsHookContext {\n buildType: BuildType;\n}\n"]}
|
package/dist/types/index.js
CHANGED
|
@@ -20,3 +20,5 @@ __reExport(types_exports, require("./config"), module.exports);
|
|
|
20
20
|
__reExport(types_exports, require("./legacyConfig"), module.exports);
|
|
21
21
|
__reExport(types_exports, require("./dts"), module.exports);
|
|
22
22
|
__reExport(types_exports, require("./context"), module.exports);
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;AAAA;AAAA;AAQA,0BAAc,oBARd;AASA,0BAAc,sBATd;AAUA,0BAAc,qBAVd;AAWA,0BAAc,2BAXd;AAYA,0BAAc,kBAZd;AAaA,0BAAc,sBAbd;","names":[],"sources":["../../src/types/index.ts"],"sourcesContent":["import { NormalizedConfig, UserConfig } from '@modern-js/core';\nimport { ModuleToolsHooks } from './hooks';\nimport { ModuleExtraConfig } from './config';\nimport type {\n ModuleToolsLegacyUserConfig,\n ModuleToolsLegacyNormalizedConfig,\n} from './legacyConfig';\n\nexport * from './hooks';\nexport * from './command';\nexport * from './config';\nexport * from './legacyConfig';\nexport * from './dts';\nexport * from './context';\nexport type { CliPlugin, IAppContext, PluginAPI } from '@modern-js/core';\n\nexport type ModuleTools = {\n hooks: ModuleToolsHooks;\n userConfig: ModuleExtraConfig;\n normalizedConfig: Required<ModuleExtraConfig>;\n};\nexport type LegacyModuleTools = {\n hooks: ModuleToolsHooks;\n userConfig: ModuleToolsLegacyUserConfig;\n normalizedConfig: ModuleToolsLegacyNormalizedConfig;\n};\n\nexport type ModuleUserConfig = UserConfig<ModuleTools>;\nexport type ModuleLegacyUserConfig = UserConfig<LegacyModuleTools>;\n\nexport type ModuleNormalizedConfig = NormalizedConfig<ModuleTools>;\nexport type ModuleLegacyNormalizedConfig = NormalizedConfig<LegacyModuleTools>;\n\n// params type for defineConfig\nexport type ModuleConfigParams =\n | ModuleUserConfig\n | Promise<ModuleUserConfig>\n | ((env: any) => ModuleUserConfig | Promise<ModuleUserConfig>);\n"]}
|
|
@@ -13,3 +13,5 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
13
13
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
14
|
var legacyConfig_exports = {};
|
|
15
15
|
module.exports = __toCommonJS(legacyConfig_exports);
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"mappings":";;;;;;;;;;;;;AAAA;AAAA;","names":[],"sources":["../../../src/types/legacyConfig/index.ts"],"sourcesContent":["import type { OutputLegacyUserConfig } from './output';\nimport type { SourceLegacyUserConfig } from './source';\n\nimport type { ToolsLegacyUserConfig } from './tools';\n\nexport type { OutputLegacyUserConfig } from './output';\n\nexport type { SourceLegacyUserConfig } from './source';\nexport type { ToolsLegacyUserConfig } from './tools';\n\nexport interface RuntimeLegacyConfig {\n [name: string]: any;\n}\n\nexport interface RuntimeByEntriesLegacyConfig {\n [name: string]: RuntimeLegacyConfig;\n}\n\nexport type ModuleToolsLegacyUserConfig = {\n source?: SourceLegacyUserConfig;\n output?: OutputLegacyUserConfig;\n tools?: ToolsLegacyUserConfig;\n runtime?: RuntimeLegacyConfig;\n legacy?: boolean;\n};\n\nexport type ModuleToolsLegacyNormalizedConfig =\n Required<ModuleToolsLegacyUserConfig>;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"mappings":";;;;;;;;;;;;;AAAA;AAAA;","names":[],"sources":["../../../src/types/legacyConfig/output.ts"],"sourcesContent":["import type { UserConfig as LibuildUserConfig } from '@modern-js/libuild';\n\nexport type LegacyBuildPreset =\n | 'npm-library'\n | 'npm-library-with-umd'\n | 'npm-component'\n | 'npm-component-with-umd';\n\nexport type LegacyFormat = 'esm' | 'cjs' | 'umd';\nexport type LegacyTarget =\n | 'es5'\n | 'es6'\n | 'es2015'\n | 'es2016'\n | 'es2017'\n | 'es2018'\n | 'es2019'\n | 'es2020'\n // The default target is esnext which means that by default, assume all of the latest JavaScript and CSS features are supported.\n | 'esnext';\nexport type LegacyBuildType = 'bundle' | 'bundleless';\nexport type LegacySourceMap = boolean | 'inline' | 'external';\n\nexport type LegacyBundleOptions = {\n entry?: Record<string, string>;\n platform?: LibuildUserConfig['platform'];\n splitting?: boolean;\n minify?: LibuildUserConfig['minify'];\n externals?: LibuildUserConfig['external'];\n skipDeps?: boolean;\n getModuleId?: (moduleName: string) => string | undefined;\n};\n\nexport type LegacyBundlelessOptions = {\n sourceDir?: string;\n style?: {\n compileMode?:\n | 'all'\n | 'only-compiled-code'\n | /* may be will be deprecated */ 'only-source-code'\n | false;\n path?: string;\n };\n static?: {\n path?: string;\n };\n};\n\nexport type LegacyBaseBuildConfig = {\n format?: LegacyFormat;\n target?: LegacyTarget;\n sourceMap?: LegacySourceMap;\n buildType?: LegacyBuildType;\n bundleOptions?: LegacyBundleOptions;\n bundlelessOptions?: LegacyBundlelessOptions;\n tsconfig?: string;\n enableDts?: boolean;\n dtsOnly?: boolean;\n outputPath?: string;\n};\n\nexport type LegacyBuildConfig = LegacyBaseBuildConfig | LegacyBaseBuildConfig[];\n\nexport type JsSyntaxType = 'CJS+ES6' | 'ESM+ES5' | 'ESM+ES6';\nexport interface PackageFields {\n main?: JsSyntaxType;\n 'jsnext:modern'?: JsSyntaxType;\n module?: JsSyntaxType;\n}\n\nexport type OutputLegacyUserConfig = {\n jsPath?: string;\n path?: string;\n copy?: Array<Record<string, unknown> & { from: string }>;\n disableTsChecker?: boolean;\n /** @deprecated Use the `buildConfig.bundlelessOptions.static.path` instead . */\n assetsPath?: string;\n /** @deprecated Use the `buildConfig.sourceMap` instead */\n disableSourceMap?: boolean;\n buildPreset?: LegacyBuildPreset;\n buildConfig?: LegacyBuildConfig;\n importStyle?: 'source-code' | 'compiled-code';\n packageMode?:\n | 'universal-js'\n | 'universal-js-lite'\n | 'browser-js'\n | 'browser-js-lite'\n | 'node-js';\n packageFields?: PackageFields;\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"mappings":";;;;;;;;;;;;;AAAA;AAAA;","names":[],"sources":["../../../src/types/legacyConfig/source.ts"],"sourcesContent":["import type { AliasOption } from '../config';\n\nexport type SourceLegacyUserConfig = {\n alias?: AliasOption;\n envVars?: Array<string>;\n globalVars?: Record<string, string>;\n jsxTransformRuntime?: 'automatic' | 'classic';\n /**\n * The configuration of `source.designSystem` is provided by `tailwindcss` plugin.\n * Please use `yarn new` or `pnpm new` to enable the corresponding capability.\n * @requires `tailwindcss` plugin\n */\n designSystem?: Record<string, any>;\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"mappings":";;;;;;;;;;;;;AAAA;AAAA;","names":[],"sources":["../../../src/types/legacyConfig/tools.ts"],"sourcesContent":["import type { JestConfig } from '@modern-js/core';\nimport type { AcceptedPlugin as PostCSSPlugin } from 'postcss';\nimport type { LessConfig, SassConfig } from '../config';\n\nexport type PostCSSOptions = {\n to?: string;\n from?: string;\n map?: any;\n syntax?: any;\n parser?: any;\n plugins?: PostCSSPlugin[];\n stringifier?: any;\n};\n\nexport type PostCSSLoaderOptions = {\n /**\n * Enable PostCSS Parser support in CSS-in-JS. If you use JS styles the postcss-js parser, add the execute option.\n */\n execute?: boolean;\n /**\n * By default generation of source maps depends on the devtool option. All values enable source map generation except eval and false value.\n */\n sourceMap?: boolean;\n /**\n * The special implementation option determines which implementation of PostCSS to use.\n */\n implementation?: unknown;\n /**\n * Allows to set PostCSS options and plugins.\n */\n postcssOptions?: PostCSSOptions;\n};\n\nexport type PostCSSConfigUtils = {\n addPlugins: (plugins: PostCSSPlugin | PostCSSPlugin[]) => void;\n};\n\ninterface ToolsConfig {\n speedy?: any | ((config: any) => any);\n}\n\nexport type PostCSSFunction = (\n options: PostCSSLoaderOptions,\n utils: PostCSSConfigUtils,\n) => PostCSSLoaderOptions | void;\n\nexport type ToolsLegacyUserConfig = {\n babel?: any;\n less?: LessConfig;\n lodash?: any;\n postcss?: PostCSSLoaderOptions | PostCSSFunction;\n sass?: SassConfig;\n speedy?: ToolsConfig['speedy'] | Array<NonNullable<ToolsConfig['speedy']>>;\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?:\n | Record<string, any>\n | ((options: Record<string, any>) => Record<string, any> | void);\n jest?: JestConfig | ((jestConfig: JestConfig) => JestConfig);\n};\n"]}
|
package/dist/types/utils.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"mappings":";;;;;;;;;;;;;AAAA;AAAA;","names":[],"sources":["../../src/types/utils.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-types\nexport type DeepPartial<T> = T extends Function\n ? T\n : T extends Array<infer U>\n ? DeepPartialArray<U>\n : T extends object\n ? DeepPartialObject<T>\n : T | undefined;\n/** @private */\nexport type DeepPartialArray<T> = Array<DeepPartial<T>>;\n/** @private */\nexport type DeepPartialObject<T> = { [P in keyof T]?: DeepPartial<T[P]> };\n"]}
|
package/dist/utils/builder.js
CHANGED
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -100,3 +104,5 @@ const getAllDeps = (_0, ..._1) => __async(void 0, [_0, ..._1], function* (appDir
|
|
|
100
104
|
getAllDeps,
|
|
101
105
|
getFinalExternals
|
|
102
106
|
});
|
|
107
|
+
|
|
108
|
+
//# sourceMappingURL=builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAGV,MAAM,oBAAoB,CAC/B,QACA,YACG;AACH,QAAM,EAAE,cAAc,UAAU,IAAI;AACpC,QAAM,EAAE,aAAa,IAAI;AAEzB,MAAI,OAAO,iBAAiB,WAAW;AACrC,QAAI,CAAC,cAAc;AACjB,aAAO,aAAa,CAAC;AAAA,IACvB;AAEA,UAAMA,QAAO,MAAM,WAAW,cAAc;AAAA,MAC1C,cAAc;AAAA,MACd,kBAAkB;AAAA,IACpB,CAAC;AACD,WAAO;AAAA,MACL,GAAGA,MAAK,IAAI,SAAO,IAAI,OAAO,IAAI,iBAAiB,CAAC;AAAA,MACpD,GAAI,aAAa,CAAC;AAAA,IACpB;AAAA,EACF;AAEA,QAAM,OAAO,MAAM,WAAW,cAAc,YAAY;AACxD,SAAO;AAAA,IACL,GAAG,KAAK,IAAI,SAAO,IAAI,OAAO,IAAI,iBAAiB,CAAC;AAAA,IACpD,GAAI,aAAa,CAAC;AAAA,EACpB;AACF;AAEO,MAAM,aAAa,CACxB,OAKG,wBALH,IAKG,mBALH,cACA,UAGI,CAAC,GACF;AACH,QAAM,EAAE,GAAG,IAAI,MAAM,6CAAO,kBAAkB;AAC9C,MAAI;AACF,UAAM,OAAO,KAAK;AAAA,MAChB,GAAG,aAAa,oBAAK,QAAQ,cAAc,gBAAgB,GAAG,MAAM;AAAA,IACtE;AAEA,QAAI,OAAiB,CAAC;AAEtB,QAAI,QAAQ,cAAc;AACxB,aAAO;AAAA,QACL,GAAG;AAAA,QACH,GAAG,OAAO,KAAM,KAAK,gBAAkC,CAAC,CAAC;AAAA,MAC3D;AAAA,IACF;AAEA,QAAI,QAAQ,kBAAkB;AAC5B,aAAO;AAAA,QACL,GAAG;AAAA,QACH,GAAG,OAAO,KAAM,KAAK,oBAAsC,CAAC,CAAC;AAAA,MAC/D;AAAA,IACF;AAEA,WAAO;AAAA,EACT,SAAS,GAAP;AACA,YAAQ,KAAK,+BAA+B;AAC5C,WAAO,CAAC;AAAA,EACV;AACF;;;;;;","names":["deps"],"sources":["../../src/utils/builder.ts"],"sourcesContent":["import path from 'path';\nimport type { BaseBuildConfig } from '../types/config';\n\nexport const getFinalExternals = async (\n config: BaseBuildConfig,\n options: { appDirectory: string },\n) => {\n const { autoExternal, externals } = config;\n const { appDirectory } = options;\n\n if (typeof autoExternal === 'boolean') {\n if (!autoExternal) {\n return externals || [];\n }\n\n const deps = await getAllDeps(appDirectory, {\n dependencies: true,\n peerDependencies: true,\n });\n return [\n ...deps.map(dep => new RegExp(`^${dep}($|\\\\/|\\\\\\\\)`)),\n ...(externals || []),\n ];\n }\n\n const deps = await getAllDeps(appDirectory, autoExternal);\n return [\n ...deps.map(dep => new RegExp(`^${dep}($|\\\\/|\\\\\\\\)`)),\n ...(externals || []),\n ];\n};\n\nexport const getAllDeps = async <T>(\n appDirectory: string,\n options: {\n dependencies?: boolean;\n peerDependencies?: boolean;\n } = {},\n) => {\n const { fs } = await import('@modern-js/utils');\n try {\n const json = JSON.parse(\n fs.readFileSync(path.resolve(appDirectory, './package.json'), 'utf8'),\n );\n\n let deps: string[] = [];\n\n if (options.dependencies) {\n deps = [\n ...deps,\n ...Object.keys((json.dependencies as T | undefined) || {}),\n ];\n }\n\n if (options.peerDependencies) {\n deps = [\n ...deps,\n ...Object.keys((json.peerDependencies as T | undefined) || {}),\n ];\n }\n\n return deps;\n } catch (e) {\n console.warn('[WARN] package.json is broken');\n return [];\n }\n};\n"]}
|
package/dist/utils/config.js
CHANGED
|
@@ -34,6 +34,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
34
34
|
return to;
|
|
35
35
|
};
|
|
36
36
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
37
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
38
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
39
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
40
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
37
41
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
38
42
|
mod
|
|
39
43
|
));
|
|
@@ -169,3 +173,5 @@ const isLegacyUserConfig = (config) => Boolean(config.legacy);
|
|
|
169
173
|
validBuildTypeAndFormat,
|
|
170
174
|
validPartialBuildConfig
|
|
171
175
|
});
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,eAAc,aAAQ,iBAAR,YAAwB,cAAc;AAAA,IACpD,YAAY,kCACP,cAAc,aACd,QAAQ;AAAA,IAEb,gBAAe,aAAQ,kBAAR,YAAyB,cAAc;AAAA,IACtD,cAAa,aAAQ,gBAAR,YAAuB,cAAc;AAAA,IAClD,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,yBACF;AAEA,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/dist/utils/context.js
CHANGED
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -56,3 +60,5 @@ const initModuleContext = (api) => __async(void 0, null, function* () {
|
|
|
56
60
|
0 && (module.exports = {
|
|
57
61
|
initModuleContext
|
|
58
62
|
});
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,oBAAoB,CAAO,QAAgC;AACtE,QAAM,EAAE,aAAa,IAAI,MAAM,6CAAO,kBAAkB;AACxD,QAAM,EAAE,cAAc,aAAa,IAAI,IAAI,cAAc;AACzD,QAAM,cAAc,aAAa,YAAY;AAE7C,SAAO,EAAE,aAAa,cAAc,aAAa;AACnD;;;;;","names":[],"sources":["../../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
|
@@ -34,6 +34,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
34
34
|
return to;
|
|
35
35
|
};
|
|
36
36
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
37
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
38
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
39
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
40
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
37
41
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
38
42
|
mod
|
|
39
43
|
));
|
|
@@ -88,6 +92,7 @@ const generatorTsConfig = (config) => __async(void 0, null, function* () {
|
|
|
88
92
|
const resetConfig = {
|
|
89
93
|
extends: extendsPath,
|
|
90
94
|
compilerOptions: {
|
|
95
|
+
// Ensure that .d.ts files are created by tsc, but not .js files
|
|
91
96
|
declaration: true,
|
|
92
97
|
emitDeclarationOnly: true,
|
|
93
98
|
outDir: tempDistAbsOurDir
|
|
@@ -159,3 +164,5 @@ const assignTsConfigPath = (config, options) => __async(void 0, null, function*
|
|
|
159
164
|
getTscBinPath,
|
|
160
165
|
resolveAlias
|
|
161
166
|
});
|
|
167
|
+
|
|
168
|
+
//# sourceMappingURL=dts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAYV,MAAM,oBAAoB,CAC/B,WACG;AACH,QAAM,EAAE,IAAI,OAAO,IAAI,MAAM,6CAAO,kBAAkB;AACtD,QAAM,EAAE,iBAAiB,IAAI,MAAM,6CAAO,kBAAkB;AAE5D,QAAM,EAAE,cAAc,WAAW,cAAc,aAAa,IAAI;AAChE,QAAM,sBAAsB,oBAAK;AAAA,IAC/B;AAAA,IACA,GAAG,oBAAoB,OAAO;AAAA,EAChC;AACA,QAAM,oBAAoB,oBAAK;AAAA,IAC7B;AAAA,IACA,oBAAK,SAAS,cAAc,YAAY;AAAA,EAC1C;AAEA,QAAM,mBAAmB,oBAAK,KAAK,qBAAqB,eAAe;AACvE,KAAG,eAAe,gBAAgB;AAElC,QAAM,cAAc,oBAAK;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AS,IACpB,iBACA,OAAO,KAAK,aAAa,EAAE,UAAU,KAAK,CAAC;AACjD,QAAM,SAAS,kBAAkB;AAAA,IAC/B,WAAW;AAAA,IACX,SAAS;AAAA,IACT,QAAO,wBAAa,oBAAb,mBAA8B,UAA9B,YAAuC,CAAC;AAAA,EACjD,CAAC;AACD,aAAW,KAAK,QAAQ;AACtB,OAAG,cAAc,EAAE,MAAM,EAAE,OAAO;AAAA,EACpC;AAEA,QAAM,GAAG,KAAK,oBAAoB,WAAW;AAC/C;AAgDO,MAAM,qBAAqB,CAChC,QACA,YACG;AAjKL;AAkKE,QAAM,EAAE,oBAAoB,IAAI,MAAM,6CAAO,kBAAkB;AAG/D,MACE,OAAO,QAAQ,aAAa,YAC5B,QAAQ,aAAa,qBACrB;AACA,WAAO,MAAM;AAAA,MACX,MAAM;AAAA,MACN,UAAU;AAAA,QACN,YAAO,QAAP,YAAc,CAAC,IAHR;AAAA,MAIX,cAAc,QAAQ;AAAA,IACxB;AAAA,EACF;AAEA,SAAO;AACT;;;;;;;;","names":[],"sources":["../../src/utils/dts.ts"],"sourcesContent":["import path from 'path';\n// import type { NodePath } from '../../compiled/@babel/traverse';\n// import type * as tt from '../../compiled/@babel/types';\n// import t from '../../compiled/@babel/types';\nimport type {\n ITsconfig,\n BundlelessGeneratorDtsConfig,\n BuildCommandOptions,\n BaseBuildConfig,\n // AliasOption,\n} from '../types';\n\nexport const generatorTsConfig = async (\n config: BundlelessGeneratorDtsConfig,\n) => {\n const { fs, nanoid } = await import('@modern-js/utils');\n const { dtsTempDirectory } = await import('../constants/dts');\n\n const { appDirectory, sourceDir: absSourceDir, tsconfigPath } = config;\n const tempDistAbsRootPath = path.join(\n appDirectory,\n `${dtsTempDirectory}/${nanoid()}`,\n );\n const tempDistAbsOurDir = path.join(\n tempDistAbsRootPath,\n path.relative(appDirectory, absSourceDir),\n );\n\n const tempTsconfigPath = path.join(tempDistAbsRootPath, `tsconfig.json`);\n fs.ensureFileSync(tempTsconfigPath);\n\n const extendsPath = path.join(\n path.relative(path.dirname(tempTsconfigPath), path.dirname(tsconfigPath)),\n path.basename(tempTsconfigPath),\n );\n\n const resetConfig: ITsconfig = {\n extends: extendsPath,\n compilerOptions: {\n // Ensure that .d.ts files are created by tsc, but not .js files\n declaration: true,\n emitDeclarationOnly: true,\n outDir: tempDistAbsOurDir,\n },\n };\n\n fs.writeJSONSync(tempTsconfigPath, resetConfig);\n\n return {\n tempTsconfigPath,\n tempDistAbsRootPath,\n tempDistAbsSrcPath: tempDistAbsOurDir,\n };\n};\n\nexport const getTscBinPath = async (appDirectory: string) => {\n const { fs } = await import('@modern-js/utils');\n const { default: findUp, exists: pathExists } = await import(\n '../../compiled/find-up'\n );\n const tscBinFile = await findUp(\n async (directory: string) => {\n const targetFilePath = path.join(directory, './node_modules/.bin/tsc');\n const hasTscBinFile = await pathExists(targetFilePath);\n if (hasTscBinFile) {\n return targetFilePath;\n }\n return undefined;\n },\n { cwd: appDirectory },\n );\n\n if (!tscBinFile || !fs.existsSync(tscBinFile)) {\n throw new Error(\n 'Failed to excute the `tsc` command, please check if `typescript` is installed correctly in the current directory.',\n );\n }\n\n return tscBinFile;\n};\n\nexport const resolveAlias = async (\n config: BundlelessGeneratorDtsConfig,\n options: {\n userTsconfig: ITsconfig;\n tempTsconfigPath: string;\n tempDistAbsRootPath: string;\n tempDistAbsSrcPath: string;\n },\n watchFilenames: string[] = [],\n) => {\n const { userTsconfig, tempDistAbsSrcPath, tempDistAbsRootPath } = options;\n const { globby, fs } = await import('@modern-js/utils');\n const { transformDtsAlias } = await import('./tspaths-transform');\n const { distAbsPath } = config;\n const dtsDistPath = `${tempDistAbsSrcPath}/**/*.d.ts`;\n const dtsFilenames =\n watchFilenames.length > 0\n ? watchFilenames\n : globby.sync(dtsDistPath, { absolute: true });\n const result = transformDtsAlias({\n filenames: dtsFilenames,\n baseUrl: tempDistAbsRootPath,\n paths: userTsconfig.compilerOptions?.paths ?? {},\n });\n for (const r of result) {\n fs.writeFileSync(r.path, r.content);\n }\n\n await fs.copy(tempDistAbsSrcPath, distAbsPath);\n};\n\n// export const matchesPattern = (calleePath: NodePath, pattern: string) => {\n// const { node } = calleePath;\n\n// if (t.isMemberExpression(node)) {\n// return calleePath.matchesPattern(pattern);\n// }\n\n// if (!t.isIdentifier(node) || pattern.includes('.')) {\n// return false;\n// }\n\n// const name = pattern.split('.')[0];\n\n// return node.name === name;\n// };\n\n// export const isImportCall = (calleePath: NodePath<tt.CallExpression>) => {\n// return t.isImport(calleePath.node.callee);\n// };\n\n// export const verifyTsConfigPaths = async (\n// tsconfigAbsPath: string,\n// userAliases?: AliasOption,\n// ) => {\n// const { readTsConfigByFile, chalk } = await import('@modern-js/utils');\n// if (!userAliases) {\n// return;\n// }\n\n// const paths = Object.keys(\n// readTsConfigByFile(tsconfigAbsPath).compilerOptions?.paths || {},\n// ).map(key => key.replace(/\\/\\*$/, ''));\n\n// Object.keys(userAliases).forEach(name => {\n// if (paths.includes(name)) {\n// throw new Error(\n// chalk.red(\n// `It looks like you have configured the alias ${chalk.bold(\n// name,\n// )} in both the modern.config file and tsconfig.json.\\n Please remove the configuration in modern.config file and just keep the configuration in tsconfig.json.`,\n// ),\n// );\n// }\n// });\n// };\n\nexport const assignTsConfigPath = async (\n config: BaseBuildConfig,\n options: BuildCommandOptions,\n) => {\n const { defaultTsConfigPath } = await import('../constants/dts');\n\n // user run `build --tsconfig './tsconfig.build.json'`\n if (\n typeof options.tsconfig === 'string' &&\n options.tsconfig !== defaultTsConfigPath\n ) {\n config.dts = {\n only: false,\n distPath: './',\n ...(config.dts ?? {}),\n tsconfigPath: options.tsconfig,\n };\n }\n\n return config;\n};\n"]}
|
package/dist/utils/input.js
CHANGED
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -109,3 +113,5 @@ const normalizeInput = (baseConfig, options) => __async(void 0, null, function*
|
|
|
109
113
|
getDefaultIndexEntry,
|
|
110
114
|
normalizeInput
|
|
111
115
|
});
|
|
116
|
+
|
|
117
|
+
//# sourceMappingURL=input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAYV,MAAM,cAAc,CAAO,OAAc,YAA0B;AACxE,QAAM,EAAE,MAAM,IAAI,MAAM,6CAAO,kBAAkB;AACjD,QAAM,EAAE,aAAa,IAAI;AAEzB,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO,MAAM;AAAA,MAAI,OACf,oBAAK,WAAW,CAAC,IAAI,MAAM,CAAC,IAAI,MAAM,oBAAK,KAAK,cAAc,CAAC,CAAC;AAAA,IAClE;AAAA,EACF;AAEA,QAAM,WAAmC,CAAC;AAC1C,aAAW,OAAO,OAAO,KAAK,KAAK,GAAG;AACpC,aAAS,GAAG,IAAI,oBAAK,WAAW,MAAM,GAAG,CAAC,IACtC,MAAM,MAAM,GAAG,CAAC,IAChB,MAAM,oBAAK,KAAK,cAAc,MAAM,GAAG,CAAC,CAAC;AAAA,EAC/C;AACA,SAAO;AACT;AAEO,MAAM,mBAAmB,CAC9B,QACA,YACG;AACH,MAAI,MAAM,QAAQ,MAAM,GAAG;AACzB,eAAW,KAAK,QAAQ;AACtB,UAAI,EAAE,cAAc,UAAU;AAC5B,UAAE,QAAQ,MAAM,qBAAqB,OAAO;AAAA,MAC9C,WAAW,EAAE,cAAc,cAAc;AACvC,UAAE,YAAY;AAAA,MAChB;AAAA,IACF;AAAA,EACF,WAAW,OAAO,cAAc,UAAU;AACxC,WAAO,QAAQ,MAAM,qBAAqB,OAAO;AAAA,EACnD,WAAW,OAAO,cAAc,cAAc;AAC5C,WAAO,YAAY;AAAA,EACrB;AAEA,SAAO;AACT;AAEO,MAAM,uBAAuB,CAAO,OAMrC,iBANqC,KAMrC,WANqC;AAAA,EACzC;AAAA,EACA;AACF,GAGM;AACJ,QAAM,EAAE,GAAG,IAAI,MAAM,6CAAO,kBAAkB;AAC9C,MAAI,QAAQ,cACR,oBAAK,KAAK,cAAc,gBAAgB,IACxC,oBAAK,KAAK,cAAc,gBAAgB;AAC5C,MAAI,GAAG,WAAW,KAAK,GAAG;AACxB,WAAO,CAAC,KAAK,oBAAK,SAAS,cAAc,KAAK,GAAG;AAAA,EACnD;AAEA,UAAQ,cACJ,oBAAK,KAAK,cAAc,iBAAiB,IACzC,oBAAK,KAAK,cAAc,iBAAiB;AAC7C,MAAI,GAAG,WAAW,KAAK,GAAG;AACxB,WAAO,CAAC,KAAK,oBAAK,SAAS,cAAc,KAAK,GAAG;AAAA,EACnD;AAEA,SAAO,CAAC;AACV;AAEO,MAAM,iBAAiB,CAC5B,YACA,YACG;AACH,MAAI,WAAW,cAAc,gBAAgB,CAAC,WAAW,OAAO;AAC9D,UAAM,EAAE,MAAM,IAAI,MAAM,6CAAO,kBAAkB;AACjD,WAAO,CAAC,MAAM,WAAW,SAAS,CAAC;AAAA,EACrC;AACA,SAAO,YAAY,WAAW,OAAO,OAAO;AAC9C;;;;;;;;","names":[],"sources":["../../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 getAbsInput = async (entry: Input, options: EntryOptions) => {\n const { slash } = await import('@modern-js/utils');\n const { appDirectory } = options;\n\n if (Array.isArray(entry)) {\n return entry.map(p =>\n path.isAbsolute(p) ? slash(p) : slash(path.join(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(path.join(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
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -64,3 +68,5 @@ const initLocalLanguage = () => __async(void 0, null, function* () {
|
|
|
64
68
|
getLocaleLanguage,
|
|
65
69
|
initLocalLanguage
|
|
66
70
|
});
|
|
71
|
+
|
|
72
|
+
//# sourceMappingURL=language.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAuB;AAEvB,MAAM,OACJ,oBAAO,KAAK,4CAA4C,OAAO;AAE1D,SAAS,oBAAoB;AAClC,QAAM,WAAW,IAAI,KAAK,uBAAuB;AACjD,SAAO,SAAS,OAAO;AACzB;AAEO,MAAM,oBAAoB,MAAY;AAC3C,QAAM,QAAQ,MAAM,6CAAO,WAAW;AACtC,QAAM,SAAS,kBAAkB;AACjC,QAAM,KAAK,eAAe,EAAE,OAAO,CAAC;AACpC,SAAO;AACT;;;;;;","names":[],"sources":["../../src/utils/language.ts"],"sourcesContent":["import { Import } from '@modern-js/utils';\n\nconst i18n: typeof import('@modern-js/plugin-i18n/language-detector') =\n Import.lazy('@modern-js/plugin-i18n/language-detector', require);\n\nexport function getLocaleLanguage() {\n const detector = new i18n.I18CLILanguageDetector();\n return detector.detect();\n}\n\nexport const initLocalLanguage = async () => {\n const local = await import('../locale');\n const locale = getLocaleLanguage();\n local.i18n.changeLanguage({ locale });\n return local;\n};\n"]}
|
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -81,3 +85,5 @@ const externalPlugin = (config, options) => {
|
|
|
81
85
|
externalPlugin,
|
|
82
86
|
watchPlugin
|
|
83
87
|
});
|
|
88
|
+
|
|
89
|
+
//# sourceMappingURL=libuild-plugins.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,cAAc,CACzB,KACA,WACkB;AAClB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM,UAAU;AACd,eAAS,MAAM,YAAY,IAAI,gBAAgB,MAAY;AACzD,cAAM,EAAE,kBAAkB,IAAI,MAAM,6CAAO,OAAO;AAClD,cAAM,EAAE,mBAAmB,IAAI,MAAM,6CAAO,kBAAkB;AAC9D,cAAM,YAAY,IAChB,OAAO,cAAc,WAAW,WAAW,gBACzC,OAAO,UAAU,OAAO;AAC5B,gBAAQ;AAAA,UACN,MAAM,kBAAkB,WAAW,mBAAmB,GAAG;AAAA,QAC3D;AACA,cAAM,SAAS,IAAI,eAAe;AAClC,eAAO,aAAa,EAAE,aAAa,OAAO,CAAC;AAAA,MAC7C,EAAC;AAAA,IACH;AAAA,EACF;AACF;AAEO,MAAM,iBAAiB,CAC5B,QACA,YACkB;AAClB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM,UAAU;AACd,eAAS,MAAM,WAAW,WAAW,mBAAmB,MAAY;AAClE,cAAM,EAAE,kBAAkB,IAAI,MAAM,6CAAO,WAAW;AACtD,cAAM,iBAAiB,MAAM,kBAAkB,QAAQ,OAAO;AAC9D,iBAAS,OAAO,WAAW;AAAA,MAC7B,EAAC;AAAA,IACH;AAAA,EACF;AACF;;;;;;","names":[],"sources":["../../src/utils/libuild-plugins.ts"],"sourcesContent":["import type { LibuildPlugin } from '@modern-js/libuild';\nimport type { BaseBuildConfig, PluginAPI, ModuleTools } from '../types';\n\nexport const watchPlugin = (\n api: PluginAPI<ModuleTools>,\n config: BaseBuildConfig,\n): LibuildPlugin => {\n return {\n name: 'watch-plugin',\n apply(compiler) {\n compiler.hooks.watchChange.tap('watch-plugin', async () => {\n const { watchSectionTitle } = await import('./log');\n const { SectionTitleStatus } = await import('../constants/log');\n const titleText = `[${\n config.buildType === 'bundle' ? 'Bundle' : 'Bundleless'\n }:${config.format}_${config.target}]`;\n console.info(\n await watchSectionTitle(titleText, SectionTitleStatus.Log),\n );\n const runner = api.useHookRunners();\n runner.buildWatchJs({ buildConfig: config });\n });\n },\n };\n};\n\nexport const externalPlugin = (\n config: BaseBuildConfig,\n options: { appDirectory: string },\n): LibuildPlugin => {\n return {\n name: 'external-plugin',\n apply(compiler) {\n compiler.hooks.initialize.tapPromise('external-plugin', async () => {\n const { getFinalExternals } = await import('./builder');\n const finalExternals = await getFinalExternals(config, options);\n compiler.config.external = finalExternals;\n });\n },\n };\n};\n"]}
|
package/dist/utils/log.js
CHANGED
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -64,3 +68,5 @@ const watchSectionTitle = (str, status) => __async(void 0, null, function* () {
|
|
|
64
68
|
0 && (module.exports = {
|
|
65
69
|
watchSectionTitle
|
|
66
70
|
});
|
|
71
|
+
|
|
72
|
+
//# sourceMappingURL=log.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAmC;AAE5B,MAAM,oBAAoB,CAC/B,KACA,WACG;AACH,QAAM,EAAE,MAAM,IAAI,MAAM,6CAAO,kBAAkB;AACjD,MAAI,WAAW,8BAAmB,SAAS;AACzC,WAAO,GAAG,MAAM,QAAQ,KAAK,UAAU,GAAG,KAAK,MAAM,MAAM;AAAA,MACzD;AAAA,IACF;AAAA,EACF,WAAW,WAAW,8BAAmB,MAAM;AAC7C,WAAO,GAAG,MAAM,QAAQ,KAAK,UAAU,GAAG,KAAK,MAAM,IAAI;AAAA,MACvD;AAAA,IACF;AAAA,EACF;AAEA,SAAO,GAAG,MAAM,QAAQ,KAAK,UAAU,GAAG,KAAK,MAAM,KAAK,UAAU,KAAK;AAC3E;;;;;","names":[],"sources":["../../src/utils/log.ts"],"sourcesContent":["import { SectionTitleStatus } from '../constants/log';\n\nexport const watchSectionTitle = async (\n str: string,\n status: SectionTitleStatus,\n) => {\n const { chalk } = await import('@modern-js/utils');\n if (status === SectionTitleStatus.Success) {\n return `${chalk.bgWhite.gray.underline(str)} ${chalk.green.underline(\n 'Successful',\n )}`;\n } else if (status === SectionTitleStatus.Fail) {\n return `${chalk.bgWhite.gray.underline(str)} ${chalk.red.underline(\n 'Build Failed',\n )}`;\n }\n\n return `${chalk.bgWhite.gray.underline(str)} ${chalk.blue.underline('Log')}`;\n};\n"]}
|
package/dist/utils/onExit.js
CHANGED
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -59,3 +63,5 @@ const addExitListener = (fn) => __async(void 0, null, function* () {
|
|
|
59
63
|
0 && (module.exports = {
|
|
60
64
|
addExitListener
|
|
61
65
|
});
|
|
66
|
+
|
|
67
|
+
//# sourceMappingURL=onExit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,kBAAkB,CAAO,OAA4B;AAChE,QAAM,EAAE,SAAS,OAAO,IAAI,MAAM,6CAAO,4BAA4B;AAErE,SAAO,CAAM,SAAQ;AACnB,QAAI,SAAS,GAAG;AACd;AAAA,IACF;AAEA,UAAM,GAAG;AAAA,EACX,EAAC;AACH;;;;;","names":[],"sources":["../../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
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -55,3 +59,5 @@ const getCompiledPath = (packageName) => __async(void 0, null, function* () {
|
|
|
55
59
|
0 && (module.exports = {
|
|
56
60
|
getCompiledPath
|
|
57
61
|
});
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEV,MAAM,kBAAkB,CAAO,gBAAwB;AAC5D,QAAM,EAAE,MAAM,IAAI,MAAM,6CAAO,kBAAkB;AACjD,SAAO,MAAM,oBAAK,KAAK,WAAW,kBAAkB,WAAW,CAAC;AAClE;;;;;","names":[],"sources":["../../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
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -77,6 +81,7 @@ const addRollupChunk = (rollupOutput, appDirectory, distDir) => {
|
|
|
77
81
|
...output.map((o) => {
|
|
78
82
|
return {
|
|
79
83
|
name: (0, import_path.relative)(appDirectory, (0, import_path.resolve)(distDir, o.fileName)),
|
|
84
|
+
// only d.ts, is outputChunk not outputAsset
|
|
80
85
|
size: o.code.length
|
|
81
86
|
};
|
|
82
87
|
})
|
|
@@ -156,3 +161,5 @@ const printBundlelessInfo = () => {
|
|
|
156
161
|
printFileSize,
|
|
157
162
|
printSucceed
|
|
158
163
|
});
|
|
164
|
+
|
|
165
|
+
//# sourceMappingURL=print.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAkC;AAElC,mBAA8B;AAK9B,iBAIO;AAOA,MAAM,cAAuB,CAAC;AAE9B,MAAM,kBAA2B,CAAC;AAElC,MAAM,iBAAiB,CAC5B,aACA,cACA,aACG;AACH,QAAM,QAAQ,MAAM,KAAK,WAAW,EAAE,IAAI,SAAO;AAC/C,UAAM,CAAC,MAAM,KAAK,IAAI;AACtB,WAAO;AAAA,MACL,UAAM,sBAAS,cAAc,IAAI;AAAA,MACjC,MAAM,MAAM,SAAS;AAA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I,QAAQ,KAAK,IAAI,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,KAAK,GAAG;AAChE;AAEA,MAAM,mBAAmB,MAAM;AAC7B,MAAI,YAAY,WAAW,GAAG;AAC5B;AAAA,EACF;AACA,QAAM,oBAAoB,YAAY;AAAA,IACpC,CAAC,KAAK,QAAQ,KAAK,IAAI,KAAK,IAAI,KAAK,MAAM;AAAA,IAC3C,+BAAoB;AAAA,EACtB;AACA,QAAM,OAAO,oBAAoB,YAAY;AAAA;AAE7C,QAAM,YACJ,iCACA,IAAI,OAAO,oBAAoB,EAAE,IACjC;AAEF,sBAAO,KAAK,mBAAM,KAAK,mBAAM,KAAK,IAAI,CAAC,CAAC;AACxC,sBAAO,IAAI,mBAAM,KAAK,mBAAM,MAAM,SAAS,CAAC,CAAC;AAE7C,cAAY,QAAQ,CAAC,EAAE,MAAM,KAAK,MAAM;AACtC,UAAM,UAAU,GAAG,OAAO,IAAI;AAAA,MAC5B,oBAAoB,KAAK,SAAS;AAAA,IACpC,IAAI,YAAY,IAAI;AACpB,wBAAO,IAAI,OAAO;AAAA,EACpB,CAAC;AACH;AAEA,MAAM,sBAAsB,MAAM;AAChC,MAAI,gBAAgB,WAAW,GAAG;AAChC;AAAA,EACF;AAEA,QAAM,QAAQ,gBAAgB;AAC9B,QAAM,YAAY,gBAAgB,OAAO,CAAC,OAAO,SAAS;AACxD,WAAO,QAAQ,KAAK;AAAA,EACtB,GAAG,CAAC;AACJ,QAAM,OAAO,wBAAwB,kCAAkC;AAAA,IACrE;AAAA,EACF;AACA,sBAAO,KAAK,mBAAM,KAAK,mBAAM,KAAK,IAAI,CAAC,CAAC;AAC1C;;;;;;;;;;;","names":[],"sources":["../../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 logger.info(\n chalk.bold(chalk.blue(`${buildSuccessText}: ${totalDuration / 1000}s`)),\n );\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 const info = `Bundle generated ${bundleFiles.length} files\\n`;\n\n const headerRow =\n reportFile1LineText +\n ' '.repeat(longestFileLength - 10) +\n reportFile2LineText;\n\n logger.info(chalk.bold(chalk.blue(info)));\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 ${prettyBytes(\n totalSize,\n )}`;\n logger.info(chalk.bold(chalk.blue(info)));\n};\n"]}
|
package/dist/utils/style.js
CHANGED
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -90,6 +94,8 @@ const getPostcssConfig = (config) => __async(void 0, null, function* () {
|
|
|
90
94
|
};
|
|
91
95
|
const mergedConfig = applyOptionsChain(
|
|
92
96
|
{
|
|
97
|
+
// TODO: when schema support redefine
|
|
98
|
+
// $$tools: 'module-tools',
|
|
93
99
|
plugins: [
|
|
94
100
|
require(yield getCompiledPath("postcss-flexbugs-fixes")),
|
|
95
101
|
require(yield getCompiledPath("postcss-custom-properties")),
|
|
@@ -125,3 +131,5 @@ const getStyleConfig = (config) => __async(void 0, null, function* () {
|
|
|
125
131
|
getSassConfig,
|
|
126
132
|
getStyleConfig
|
|
127
133
|
});
|
|
134
|
+
|
|
135
|
+
//# sourceMappingURL=style.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASO,MAAM,gBAAgB,CAAO,WAAmC;AATvE;AAUE,QAAM,EAAE,kBAAkB,IAAI,MAAM,6CAAO,kBAAkB;AAC7D,QAAM,EAAE,gBAAgB,IAAI,MAAM,6CAAO,QAAQ;AAEjD,QAAM,gBAAgB;AAAA,IACpB;AAAA,MACE,aAAa,EAAE,mBAAmB,KAAK;AAAA,MACvC,gBAAgB,MAAM,gBAAgB,MAAM;AAAA,IAC9C;AAAA,MACA,sCAAQ,UAAR,mBAAe,SAAQ,CAAC;AAAA,EAC1B;AAEA,SAAO;AACT;AAEO,MAAM,gBAAgB,CAAO,WAAmC;AAxBvE;AAyBE,QAAM,EAAE,kBAAkB,IAAI,MAAM,6CAAO,kBAAkB;AAC7D,QAAM,EAAE,gBAAgB,IAAI,MAAM,6CAAO,QAAQ;AAEjD,QAAM,gBAAgB;AAAA,IACpB;AAAA,MACE,gBAAgB,MAAM,gBAAgB,MAAM;AAAA,IAC9C;AAAA,MACA,sCAAQ,UAAR,mBAAe,SAAQ,CAAC;AAAA,EAC1B;AAEA,SAAO;AACT;AAEO,MAAM,mBAAmB,CAAO,WAAmC;AAtC1E;AAuCE,QAAM,EAAE,kBAAkB,IAAI,MAAM,6CAAO,kBAAkB;AAC7D,QAAM,EAAE,gBAAgB,IAAI,MAAM,6CAAO,QAAQ;AACjD,QAAM,eAAiC,CAAC;AAExC,QAAM,QAAQ;AAAA,IACZ,WAAW,SAA4C;AACrD,UAAI,MAAM,QAAQ,OAAO,GAAG;AAC1B,qBAAa,KAAK,GAAG,OAAO;AAAA,MAC9B,OAAO;AACL,qBAAa,KAAK,OAAO;AAAA,MAC3B;AAAA,IACF;AAAA,EACF;AAEA,QAAM,eAAe;AAAA,IAInB;AAAA;AAAA;AAAA,MAGE,SAAS;AAAA,QACP,QAAQ,MAAM,gBAAgB,wBAAwB,CAAC;AAAA,QACvD,QAAQ,MAAM,gBAAgB,2BAA2B,CAAC;AAAA,QAC1D,QAAQ,MAAM,gBAAgB,iBAAiB,CAAC;AAAA,QAChD,QAAQ,MAAM,gBAAgB,oBAAoB,CAAC;AAAA,QACnD,QAAQ,MAAM,gBAAgB,sBAAsB,CAAC;AAAA,QACrD,QAAQ,MAAM,gBAAgB,sBAAsB,CAAC;AAAA,QACrD,QAAQ,MAAM,gBAAgB,iBAAiB,CAAC;AAAA,MAClD,EAAE,OAAO,OAAO;AAAA,IAClB;AAAA,MACA,sCAAQ,UAAR,mBAAe,YAAW,CAAC;AAAA,IAC3B;AAAA,EACF;AACA,MAAI,aAAa,QAAQ;AACvB,iBAAa,QAAS,KAAK,GAAG,YAAY;AAAA,EAC5C;AAEA,SAAO;AACT;AAEO,MAAM,iBAAiB,CAAO,WAAmC;AACtE,QAAM,gBAAgB,MAAM,iBAAiB,MAAM;AACnD,QAAM,aAAa,MAAM,cAAc,MAAM;AAC7C,QAAM,aAAa,MAAM,cAAc,MAAM;AAC7C,SAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AACF;;;;;;;;","names":[],"sources":["../../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"]}
|
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -84,9 +88,12 @@ const transformSingleFileAlias = ({
|
|
|
84
88
|
const ast = parser.parse(sourceCode, {
|
|
85
89
|
sourceType: "module",
|
|
86
90
|
errorRecovery: true,
|
|
91
|
+
// 防止typescript不支持的语法出现而报错
|
|
87
92
|
plugins: ["typescript"]
|
|
88
93
|
});
|
|
89
94
|
(0, import_traverse.default)(ast, {
|
|
95
|
+
// d.ts file content not have callExpression which can be parsed;
|
|
96
|
+
// CallExpression: transformCall({ filename, baseUrl, paths }) as any,
|
|
90
97
|
ImportDeclaration: transformImport({
|
|
91
98
|
filename,
|
|
92
99
|
baseUrl,
|
|
@@ -115,3 +122,5 @@ const transformDtsAlias = (option) => {
|
|
|
115
122
|
0 && (module.exports = {
|
|
116
123
|
transformDtsAlias
|
|
117
124
|
});
|
|
125
|
+
|
|
126
|
+
//# sourceMappingURL=tspaths-transform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,WAAsB;AACtB,4BAAgC;AAChC,mBAAmB;AACnB,aAAwB;AACxB,uBAAsB;AACtB,QAAmB;AACnB,sBAAmC;AACnC,kBAA6B;AAU7B,SAAS,cACP,UACA,EAAE,UAAU,SAAS,MAAM,GAC3B;AACA,MAAI,CAAC,EAAE,gBAAgB,QAAQ,GAAG;AAChC;AAAA,EAC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ACF,CAAC;AAAA,IACD,mBAAmB,gBAAgB;AAAA,MACjC;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AACD,aAAO,0BAAU,GAAG,EAAE;AACxB;AAOO,MAAM,oBAAoB,CAAC,WAAoC;AACpE,QAAM,EAAE,YAAY,CAAC,GAAG,SAAS,MAAM,IAAI;AAC3C,QAAM,kBAAuD,CAAC;AAC9D,aAAW,YAAY,WAAW;AAChC,oBAAgB,KAAK;AAAA,MACnB,MAAM;AAAA,MACN,SAAS,yBAAyB,EAAE,UAAU,SAAS,MAAM,CAAC;AAAA,IAChE,CAAC;AAAA,EACH;AACA,SAAO;AACT;;;;;","names":[],"sources":["../../src/utils/tspaths-transform.ts"],"sourcesContent":["import * as path from 'path';\nimport { createMatchPath } from '@modern-js/utils/tsconfig-paths';\nimport { fs } from '@modern-js/utils';\nimport * as parser from '../../compiled/@babel/parser';\nimport generator from '../../compiled/@babel/generator';\nimport * as t from '../../compiled/@babel/types';\nimport traverse, { NodePath } from '../../compiled/@babel/traverse';\nimport { dtsAliasExts } from '../constants/file';\n// import { defaultTransformedFunctions } from '../constants/dts';\n// import { matchesPattern, isImportCall } from './dts';\n\nexport interface TransformOption {\n filename: string;\n baseUrl: string;\n paths: Record<string, string[] | string>;\n}\n\nfunction mapPathString(\n nodePath: NodePath<t.StringLiteral>,\n { filename, baseUrl, paths }: TransformOption,\n) {\n if (!t.isStringLiteral(nodePath)) {\n return;\n }\n\n const sourcePath = nodePath.node.value;\n const currentFile = filename;\n const matchPath = createMatchPath(\n baseUrl,\n paths as { [key: string]: Array<string> },\n ['index'],\n );\n const result = matchPath(\n sourcePath,\n packageJsonPath => {\n if (!fs.existsSync(packageJsonPath)) {\n return undefined;\n }\n return fs.readJSONSync(packageJsonPath);\n },\n filePath => fs.existsSync(filePath),\n dtsAliasExts,\n );\n if (result) {\n const relativePath = path.relative(\n path.dirname(currentFile),\n path.dirname(result),\n );\n const fileName = path.basename(result);\n // 如果是同级文件,则返回的是 ''\n const filePath = path.normalize(\n `${relativePath.length === 0 ? '.' : relativePath}/${fileName}`,\n );\n const replaceString = filePath.startsWith('.') ? filePath : `./${filePath}`;\n nodePath.replaceWith(t.stringLiteral(replaceString));\n }\n}\n\n// const transformCall =\n// (option: TransformOption) => (nodePath: NodePath<t.CallExpression>) => {\n// const calleePath = nodePath.get('callee') as NodePath;\n// const isNormalCall = defaultTransformedFunctions.some(pattern =>\n// matchesPattern(calleePath, pattern),\n// );\n// if (isNormalCall || isImportCall(nodePath)) {\n// mapPathString(\n// nodePath.get('arguments.0') as NodePath<t.StringLiteral>,\n// option,\n// );\n// }\n// };\n\nconst transformImport =\n (option: TransformOption) => (nodePath: NodePath<t.ImportDeclaration>) => {\n mapPathString(nodePath.get('source'), option);\n };\n\nconst transformExport =\n (option: TransformOption) => (nodePath: NodePath<t.ExportDeclaration>) => {\n mapPathString(nodePath.get('source') as NodePath<t.StringLiteral>, option);\n };\n\nconst transformSingleFileAlias = ({\n filename,\n baseUrl,\n paths,\n}: TransformOption) => {\n const sourceCode = fs.readFileSync(filename, 'utf-8');\n const ast = parser.parse(sourceCode, {\n sourceType: 'module',\n errorRecovery: true, // 防止typescript不支持的语法出现而报错\n plugins: ['typescript'],\n });\n traverse(ast, {\n // d.ts file content not have callExpression which can be parsed;\n // CallExpression: transformCall({ filename, baseUrl, paths }) as any,\n ImportDeclaration: transformImport({\n filename,\n baseUrl,\n paths,\n }) as any,\n ExportDeclaration: transformExport({\n filename,\n baseUrl,\n paths,\n }) as any,\n });\n return generator(ast).code;\n};\n\ninterface TransformDtsAliasOption {\n filenames?: string[];\n baseUrl: string;\n paths: Record<string, string[] | string>;\n}\nexport const transformDtsAlias = (option: TransformDtsAliasOption) => {\n const { filenames = [], baseUrl, paths } = option;\n const transformResult: { path: string; content: string }[] = [];\n for (const filename of filenames) {\n transformResult.push({\n path: filename,\n content: transformSingleFileAlias({ filename, baseUrl, paths }),\n });\n }\n return transformResult;\n};\n"]}
|