@modern-js/module-tools 2.0.0-beta.2 → 2.0.0-beta.4
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 +276 -205
- package/bin/modern.js +7 -1
- package/compiled/@babel/code-frame/index.d.ts +1 -0
- package/compiled/@babel/code-frame/index.js +1 -0
- package/compiled/@babel/code-frame/license +22 -0
- package/compiled/@babel/code-frame/package.json +1 -0
- package/compiled/@babel/generator/index.d.ts +1 -0
- package/compiled/@babel/generator/index.js +1 -0
- package/compiled/@babel/generator/license +22 -0
- package/compiled/@babel/generator/package.json +1 -0
- package/compiled/@babel/helper-validator-identifier/index.d.ts +1 -0
- package/compiled/@babel/helper-validator-identifier/index.js +1 -0
- package/compiled/@babel/helper-validator-identifier/license +22 -0
- package/compiled/@babel/helper-validator-identifier/package.json +1 -0
- package/compiled/@babel/highlight/index.d.ts +1 -0
- package/compiled/@babel/highlight/index.js +1 -0
- package/compiled/@babel/highlight/license +22 -0
- package/compiled/@babel/highlight/package.json +1 -0
- package/compiled/@babel/parser/@babel/types/lib/index-legacy.d.ts +2742 -0
- package/compiled/@babel/parser/index.js +1 -0
- package/compiled/@babel/parser/license +19 -0
- package/compiled/@babel/parser/package.json +1 -0
- package/compiled/@babel/parser/typings/babel-parser.d.ts +214 -0
- package/compiled/@babel/template/index.d.ts +1 -0
- package/compiled/@babel/template/index.js +1 -0
- package/compiled/@babel/template/license +22 -0
- package/compiled/@babel/template/package.json +1 -0
- package/compiled/@babel/traverse/index.d.ts +1199 -0
- package/compiled/@babel/traverse/index.js +1 -0
- package/compiled/@babel/traverse/license +22 -0
- package/compiled/@babel/traverse/package.json +1 -0
- package/compiled/@babel/types/index.js +1 -0
- package/compiled/@babel/types/lib/index-legacy.d.ts +2732 -0
- package/compiled/@babel/types/license +22 -0
- package/compiled/@babel/types/package.json +1 -0
- package/compiled/@rollup/plugin-json/@rollup/pluginutils/types/index.d.ts +86 -0
- package/compiled/@rollup/plugin-json/estree/index.d.ts +548 -0
- package/compiled/@rollup/plugin-json/index.js +1 -0
- package/compiled/@rollup/plugin-json/license +21 -0
- package/compiled/@rollup/plugin-json/package.json +1 -0
- package/compiled/@rollup/plugin-json/rollup/dist/rollup.d.ts +948 -0
- package/compiled/@rollup/plugin-json/types/index.d.ts +41 -0
- package/compiled/find-up/index.d.ts +138 -0
- package/compiled/find-up/index.js +1 -0
- package/compiled/find-up/license +9 -0
- package/compiled/find-up/locate-path/index.d.ts +83 -0
- package/compiled/find-up/package.json +1 -0
- package/compiled/less/index.d.ts +282 -0
- package/compiled/less/index.js +1 -0
- package/compiled/less/package.json +1 -0
- package/compiled/normalize-path/index.d.ts +8 -0
- package/compiled/normalize-path/index.js +8 -0
- package/compiled/normalize-path/license +21 -0
- package/compiled/normalize-path/package.json +1 -0
- package/compiled/p-map/@szmarczak/http-timer/dist/source/index.d.ts +32 -0
- package/compiled/p-map/cacheable-lookup/index.d.ts +139 -0
- package/compiled/p-map/cacheable-request/index.d.ts +137 -0
- package/compiled/p-map/got/dist/source/as-promise/index.d.ts +3 -0
- package/compiled/p-map/got/dist/source/as-promise/types.d.ts +256 -0
- package/compiled/p-map/got/dist/source/core/index.d.ts +1124 -0
- package/compiled/p-map/got/dist/source/core/utils/dns-ip-version.d.ts +5 -0
- package/compiled/p-map/got/dist/source/core/utils/options-to-url.d.ts +14 -0
- package/compiled/p-map/got/dist/source/core/utils/timed-out.d.ts +29 -0
- package/compiled/p-map/got/dist/source/index.d.ts +4 -0
- package/compiled/p-map/got/dist/source/types.d.ts +344 -0
- package/compiled/p-map/http-cache-semantics/index.d.ts +170 -0
- package/compiled/p-map/index.d.ts +67 -0
- package/compiled/p-map/index.js +1 -0
- package/compiled/p-map/keyv/src/index.d.ts +104 -0
- package/compiled/p-map/license +9 -0
- package/compiled/p-map/p-cancelable/index.d.ts +176 -0
- package/compiled/p-map/package.json +1 -0
- package/compiled/p-map/responselike/index.d.ts +34 -0
- package/compiled/postcss-custom-properties/index.d.ts +1 -0
- package/compiled/postcss-custom-properties/index.js +1 -0
- package/compiled/postcss-custom-properties/package.json +1 -0
- package/compiled/postcss-flexbugs-fixes/index.d.ts +1 -0
- package/compiled/postcss-flexbugs-fixes/index.js +1 -0
- package/compiled/postcss-flexbugs-fixes/license +20 -0
- package/compiled/postcss-flexbugs-fixes/package.json +1 -0
- package/compiled/postcss-font-variant/index.d.ts +1 -0
- package/compiled/postcss-font-variant/index.js +1 -0
- package/compiled/postcss-font-variant/license +20 -0
- package/compiled/postcss-font-variant/package.json +1 -0
- package/compiled/postcss-initial/index.d.ts +1 -0
- package/compiled/postcss-initial/index.js +1 -0
- package/compiled/postcss-initial/license +20 -0
- package/compiled/postcss-initial/package.json +1 -0
- package/compiled/postcss-media-minmax/index.d.ts +1 -0
- package/compiled/postcss-media-minmax/index.js +1 -0
- package/compiled/postcss-media-minmax/license +22 -0
- package/compiled/postcss-media-minmax/package.json +1 -0
- package/compiled/postcss-nesting/index.d.ts +1 -0
- package/compiled/postcss-nesting/index.js +2 -0
- package/compiled/postcss-nesting/package.json +1 -0
- package/compiled/postcss-page-break/index.d.ts +1 -0
- package/compiled/postcss-page-break/index.js +1 -0
- package/compiled/postcss-page-break/license +20 -0
- package/compiled/postcss-page-break/package.json +1 -0
- package/compiled/postcss-value-parser/index.d.ts +1 -0
- package/compiled/postcss-value-parser/index.js +1 -0
- package/compiled/postcss-value-parser/license +22 -0
- package/compiled/postcss-value-parser/package.json +1 -0
- package/compiled/rollup/fsevents.node +0 -0
- package/compiled/rollup/index.js +82 -0
- package/compiled/rollup/package.json +1 -0
- package/compiled/rollup/types/rollup.d.ts +948 -0
- package/compiled/rollup-plugin-dts/dist/rollup-plugin-dts.d.ts +21 -0
- package/compiled/rollup-plugin-dts/index.js +1 -0
- package/compiled/rollup-plugin-dts/package.json +1 -0
- package/compiled/rollup-plugin-dts/rollup/dist/rollup.d.ts +948 -0
- package/compiled/sass/index.js +1 -0
- package/compiled/sass/license +1619 -0
- package/compiled/sass/package.json +1 -0
- package/compiled/sass/types/compile.d.ts +152 -0
- package/compiled/sass/types/exception.d.ts +41 -0
- package/compiled/sass/types/importer.d.ts +294 -0
- package/compiled/sass/types/index.d.ts +80 -0
- package/compiled/sass/types/legacy/exception.d.ts +54 -0
- package/compiled/sass/types/legacy/function.d.ts +756 -0
- package/compiled/sass/types/legacy/importer.d.ts +168 -0
- package/compiled/sass/types/legacy/options.d.ts +642 -0
- package/compiled/sass/types/legacy/plugin_this.d.ts +73 -0
- package/compiled/sass/types/legacy/render.d.ts +139 -0
- package/compiled/sass/types/logger/index.d.ts +94 -0
- package/compiled/sass/types/logger/source_location.d.ts +21 -0
- package/compiled/sass/types/logger/source_span.d.ts +34 -0
- package/compiled/sass/types/options.d.ts +435 -0
- package/compiled/sass/types/util/promise_or.d.ts +17 -0
- package/compiled/sass/types/value/argument_list.d.ts +47 -0
- package/compiled/sass/types/value/boolean.d.ts +29 -0
- package/compiled/sass/types/value/color.d.ts +107 -0
- package/compiled/sass/types/value/function.d.ts +22 -0
- package/compiled/sass/types/value/index.d.ts +173 -0
- package/compiled/sass/types/value/list.d.ts +54 -0
- package/compiled/sass/types/value/map.d.ts +41 -0
- package/compiled/sass/types/value/number.d.ts +305 -0
- package/compiled/sass/types/value/string.d.ts +84 -0
- package/compiled/signal-exit/index.d.ts +24 -0
- package/compiled/signal-exit/index.js +1 -0
- package/compiled/signal-exit/package.json +1 -0
- package/dist/builder/build.d.ts +23 -0
- package/dist/builder/build.js +265 -0
- package/dist/builder/build.js.map +1 -0
- package/dist/builder/clear.d.ts +3 -0
- package/dist/builder/clear.js +74 -0
- package/dist/builder/clear.js.map +1 -0
- package/dist/builder/copy.d.ts +9 -0
- package/dist/builder/copy.js +207 -0
- package/dist/builder/copy.js.map +1 -0
- package/dist/builder/dts/index.d.ts +2 -0
- package/dist/builder/dts/index.js +27 -0
- package/dist/builder/dts/index.js.map +1 -0
- package/dist/builder/dts/rollup.d.ts +17 -0
- package/dist/builder/dts/rollup.js +180 -0
- package/dist/builder/dts/rollup.js.map +1 -0
- package/dist/builder/dts/tsc.d.ts +3 -0
- package/dist/builder/dts/tsc.js +160 -0
- package/dist/builder/dts/tsc.js.map +1 -0
- package/dist/builder/index.d.ts +8 -0
- package/dist/builder/index.js +124 -0
- package/dist/builder/index.js.map +1 -0
- package/dist/builder/platform.d.ts +4 -0
- package/dist/builder/platform.js +140 -0
- package/dist/builder/platform.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +103 -0
- package/dist/cli.js.map +1 -0
- package/dist/command.d.ts +7 -0
- package/dist/command.js +169 -0
- package/dist/command.js.map +1 -0
- package/dist/config/defineConfig.d.ts +2 -0
- package/dist/config/defineConfig.js +25 -0
- package/dist/config/defineConfig.js.map +1 -0
- package/dist/config/normalize.d.ts +17 -0
- package/dist/config/normalize.js +177 -0
- package/dist/config/normalize.js.map +1 -0
- package/dist/config/schema.d.ts +641 -0
- package/dist/config/schema.js +207 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/constants/build-presets.d.ts +81 -0
- package/dist/constants/build-presets.js +219 -0
- package/dist/constants/build-presets.js.map +1 -0
- package/dist/constants/build.d.ts +5 -0
- package/dist/constants/build.js +71 -0
- package/dist/constants/build.js.map +1 -0
- package/dist/constants/colors.d.ts +4 -0
- package/dist/constants/colors.js +29 -0
- package/dist/constants/colors.js.map +1 -0
- package/dist/constants/dts.d.ts +4 -0
- package/dist/constants/dts.js +45 -0
- package/dist/constants/dts.js.map +1 -0
- package/dist/constants/file.d.ts +3 -0
- package/dist/constants/file.js +29 -0
- package/dist/constants/file.js.map +1 -0
- package/dist/constants/legacy-build-presets.d.ts +13 -0
- package/dist/constants/legacy-build-presets.js +189 -0
- package/dist/constants/legacy-build-presets.js.map +1 -0
- package/dist/constants/log.d.ts +8 -0
- package/dist/constants/log.js +36 -0
- package/dist/constants/log.js.map +1 -0
- package/dist/dev.d.ts +10 -0
- package/dist/dev.js +135 -0
- package/dist/dev.js.map +1 -0
- package/dist/{types/features/build/error.d.ts → error.d.ts} +1 -1
- package/dist/error.js +139 -0
- package/dist/error.js.map +1 -0
- package/dist/hooks/build.d.ts +22 -0
- package/dist/hooks/build.js +35 -0
- package/dist/hooks/build.js.map +1 -0
- package/dist/hooks/dev.d.ts +12 -0
- package/dist/hooks/dev.js +33 -0
- package/dist/hooks/dev.js.map +1 -0
- package/dist/hooks/index.d.ts +29 -0
- package/dist/hooks/index.js +44 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/misc.d.ts +5 -0
- package/dist/hooks/misc.js +29 -0
- package/dist/hooks/misc.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/{types/locale → locale}/en.d.ts +0 -0
- package/dist/locale/en.js +47 -0
- package/dist/locale/en.js.map +1 -0
- package/dist/{types/locale → locale}/index.d.ts +0 -0
- package/dist/locale/index.js +34 -0
- package/dist/locale/index.js.map +1 -0
- package/dist/{types/locale → locale}/zh.d.ts +0 -0
- package/dist/locale/zh.js +47 -0
- package/dist/locale/zh.js.map +1 -0
- package/dist/plugins.d.ts +2 -0
- package/dist/plugins.js +51 -0
- package/dist/plugins.js.map +1 -0
- package/dist/types/color.d.ts +1 -0
- package/dist/{js/modern/features/build/types.js → types/color.js} +0 -0
- package/dist/types/command.d.ts +11 -0
- package/dist/{js/modern/schema/types.js → types/command.js} +0 -0
- package/dist/types/config/index.d.ts +95 -0
- package/dist/types/config/index.js +19 -0
- package/dist/types/config/index.js.map +1 -0
- package/dist/types/config/style.d.ts +12 -0
- package/dist/{js/modern/types.js → types/config/style.js} +0 -0
- package/dist/types/context.d.ts +5 -0
- package/dist/{js/node/features/build/types.js → types/context.js} +0 -0
- package/dist/types/copy.d.ts +15 -0
- package/dist/{js/node/schema/types.js → types/copy.js} +0 -0
- package/dist/types/{utils/tsconfig.d.ts → dts.d.ts} +11 -3
- package/dist/{js/node/types.js → types/dts.js} +0 -0
- package/dist/types/hooks.d.ts +25 -0
- package/dist/types/hooks.js +0 -0
- package/dist/types/index.d.ts +17 -6
- package/dist/types/index.js +23 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/utils.d.ts +7 -0
- package/dist/types/utils.js +0 -0
- package/dist/utils/builder.d.ts +8 -0
- package/dist/utils/builder.js +117 -0
- package/dist/utils/builder.js.map +1 -0
- package/dist/utils/config.d.ts +6 -0
- package/dist/utils/config.js +172 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/context.d.ts +7 -0
- package/dist/utils/context.js +68 -0
- package/dist/utils/context.js.map +1 -0
- package/dist/utils/dts.d.ts +14 -0
- package/dist/utils/dts.js +197 -0
- package/dist/utils/dts.js.map +1 -0
- package/dist/utils/input.d.ts +16 -0
- package/dist/utils/input.js +124 -0
- package/dist/utils/input.js.map +1 -0
- package/dist/utils/language.d.ts +2 -0
- package/dist/utils/language.js +75 -0
- package/dist/utils/language.js.map +1 -0
- package/dist/utils/libuild-plugins.d.ts +6 -0
- package/dist/utils/libuild-plugins.js +90 -0
- package/dist/utils/libuild-plugins.js.map +1 -0
- package/dist/utils/log.d.ts +2 -0
- package/dist/utils/log.js +76 -0
- package/dist/utils/log.js.map +1 -0
- package/dist/utils/onExit.d.ts +1 -0
- package/dist/utils/onExit.js +71 -0
- package/dist/utils/onExit.js.map +1 -0
- package/dist/utils/path.d.ts +1 -0
- package/dist/utils/path.js +73 -0
- package/dist/utils/path.js.map +1 -0
- package/dist/utils/style.d.ts +31 -0
- package/dist/utils/style.js +134 -0
- package/dist/utils/style.js.map +1 -0
- package/dist/{types/utils/tspaths-transform/index.d.ts → utils/tspaths-transform.d.ts} +0 -0
- package/dist/utils/tspaths-transform.js +115 -0
- package/dist/utils/tspaths-transform.js.map +1 -0
- package/package.json +47 -73
- package/dist/js/modern/cli/build.js +0 -11
- package/dist/js/modern/cli/dev.js +0 -11
- package/dist/js/modern/cli/index.js +0 -3
- package/dist/js/modern/cli/new.js +0 -13
- package/dist/js/modern/commands/build.js +0 -69
- package/dist/js/modern/commands/dev.js +0 -43
- package/dist/js/modern/commands/index.js +0 -2
- package/dist/js/modern/features/build/build-platform.js +0 -69
- package/dist/js/modern/features/build/bundle/index.js +0 -9
- package/dist/js/modern/features/build/bundle/runRollup.js +0 -136
- package/dist/js/modern/features/build/bundle/runSpeedy.js +0 -176
- package/dist/js/modern/features/build/bundleless/copy-assets.js +0 -75
- package/dist/js/modern/features/build/bundleless/generator-dts/index.js +0 -106
- package/dist/js/modern/features/build/bundleless/generator-dts/utils.js +0 -94
- package/dist/js/modern/features/build/bundleless/index.js +0 -21
- package/dist/js/modern/features/build/bundleless/runBabel.js +0 -242
- package/dist/js/modern/features/build/bundleless/style.js +0 -241
- package/dist/js/modern/features/build/constants.js +0 -98
- package/dist/js/modern/features/build/error.js +0 -127
- package/dist/js/modern/features/build/index.js +0 -117
- package/dist/js/modern/features/build/legacy-constants.js +0 -103
- package/dist/js/modern/features/build/logger/index.js +0 -2
- package/dist/js/modern/features/build/logger/logText.js +0 -56
- package/dist/js/modern/features/build/logger/loggerManager.js +0 -93
- package/dist/js/modern/features/build/normalize.js +0 -277
- package/dist/js/modern/features/build/utils.js +0 -92
- package/dist/js/modern/features/dev/index.js +0 -47
- package/dist/js/modern/hooks/build.js +0 -20
- package/dist/js/modern/hooks/dev.js +0 -14
- package/dist/js/modern/hooks/index.js +0 -15
- package/dist/js/modern/index.js +0 -63
- package/dist/js/modern/locale/en.js +0 -25
- package/dist/js/modern/locale/index.js +0 -10
- package/dist/js/modern/locale/zh.js +0 -25
- package/dist/js/modern/schema/build-config.js +0 -117
- package/dist/js/modern/schema/index.js +0 -4
- package/dist/js/modern/schema/output.js +0 -45
- package/dist/js/modern/schema/source.js +0 -7
- package/dist/js/modern/schema/tools.js +0 -6
- package/dist/js/modern/utils/babel.js +0 -84
- package/dist/js/modern/utils/color.js +0 -2
- package/dist/js/modern/utils/constants.js +0 -3
- package/dist/js/modern/utils/copy.js +0 -70
- package/dist/js/modern/utils/init-env.js +0 -13
- package/dist/js/modern/utils/json.js +0 -13
- package/dist/js/modern/utils/language.js +0 -6
- package/dist/js/modern/utils/logger.js +0 -96
- package/dist/js/modern/utils/readline.js +0 -17
- package/dist/js/modern/utils/tsconfig.js +0 -13
- package/dist/js/modern/utils/tspaths-transform/constants.js +0 -5
- package/dist/js/modern/utils/tspaths-transform/index.js +0 -113
- package/dist/js/modern/utils/tspaths-transform/utils.js +0 -18
- package/dist/js/modern/utils/valide.js +0 -26
- package/dist/js/node/cli/build.js +0 -18
- package/dist/js/node/cli/dev.js +0 -18
- package/dist/js/node/cli/index.js +0 -38
- package/dist/js/node/cli/new.js +0 -20
- package/dist/js/node/commands/build.js +0 -80
- package/dist/js/node/commands/dev.js +0 -52
- package/dist/js/node/commands/index.js +0 -19
- package/dist/js/node/features/build/build-platform.js +0 -76
- package/dist/js/node/features/build/bundle/index.js +0 -17
- package/dist/js/node/features/build/bundle/runRollup.js +0 -145
- package/dist/js/node/features/build/bundle/runSpeedy.js +0 -186
- package/dist/js/node/features/build/bundleless/copy-assets.js +0 -84
- package/dist/js/node/features/build/bundleless/generator-dts/index.js +0 -114
- package/dist/js/node/features/build/bundleless/generator-dts/utils.js +0 -105
- package/dist/js/node/features/build/bundleless/index.js +0 -29
- package/dist/js/node/features/build/bundleless/runBabel.js +0 -255
- package/dist/js/node/features/build/bundleless/style.js +0 -254
- package/dist/js/node/features/build/constants.js +0 -116
- package/dist/js/node/features/build/error.js +0 -139
- package/dist/js/node/features/build/index.js +0 -128
- package/dist/js/node/features/build/legacy-constants.js +0 -111
- package/dist/js/node/features/build/logger/index.js +0 -27
- package/dist/js/node/features/build/logger/logText.js +0 -66
- package/dist/js/node/features/build/logger/loggerManager.js +0 -95
- package/dist/js/node/features/build/normalize.js +0 -288
- package/dist/js/node/features/build/utils.js +0 -107
- package/dist/js/node/features/dev/index.js +0 -56
- package/dist/js/node/hooks/build.js +0 -32
- package/dist/js/node/hooks/dev.js +0 -24
- package/dist/js/node/hooks/index.js +0 -36
- package/dist/js/node/index.js +0 -83
- package/dist/js/node/locale/en.js +0 -32
- package/dist/js/node/locale/index.js +0 -17
- package/dist/js/node/locale/zh.js +0 -32
- package/dist/js/node/schema/build-config.js +0 -126
- package/dist/js/node/schema/index.js +0 -11
- package/dist/js/node/schema/output.js +0 -52
- package/dist/js/node/schema/source.js +0 -14
- package/dist/js/node/schema/tools.js +0 -13
- package/dist/js/node/utils/babel.js +0 -93
- package/dist/js/node/utils/color.js +0 -9
- package/dist/js/node/utils/constants.js +0 -11
- package/dist/js/node/utils/copy.js +0 -79
- package/dist/js/node/utils/init-env.js +0 -20
- package/dist/js/node/utils/json.js +0 -20
- package/dist/js/node/utils/language.js +0 -12
- package/dist/js/node/utils/logger.js +0 -107
- package/dist/js/node/utils/readline.js +0 -25
- package/dist/js/node/utils/tsconfig.js +0 -21
- package/dist/js/node/utils/tspaths-transform/constants.js +0 -12
- package/dist/js/node/utils/tspaths-transform/index.js +0 -123
- package/dist/js/node/utils/tspaths-transform/utils.js +0 -25
- package/dist/js/node/utils/valide.js +0 -34
- package/dist/types/cli/build.d.ts +0 -3
- package/dist/types/cli/dev.d.ts +0 -3
- package/dist/types/cli/index.d.ts +0 -3
- package/dist/types/cli/new.d.ts +0 -2
- package/dist/types/commands/build.d.ts +0 -17
- package/dist/types/commands/dev.d.ts +0 -5
- package/dist/types/commands/index.d.ts +0 -2
- package/dist/types/features/build/build-platform.d.ts +0 -7
- package/dist/types/features/build/bundle/index.d.ts +0 -3
- package/dist/types/features/build/bundle/runRollup.d.ts +0 -3
- package/dist/types/features/build/bundle/runSpeedy.d.ts +0 -10
- package/dist/types/features/build/bundleless/copy-assets.d.ts +0 -3
- package/dist/types/features/build/bundleless/generator-dts/index.d.ts +0 -3
- package/dist/types/features/build/bundleless/generator-dts/utils.d.ts +0 -21
- package/dist/types/features/build/bundleless/index.d.ts +0 -4
- package/dist/types/features/build/bundleless/runBabel.d.ts +0 -32
- package/dist/types/features/build/bundleless/style.d.ts +0 -25
- package/dist/types/features/build/constants.d.ts +0 -18
- package/dist/types/features/build/index.d.ts +0 -12
- package/dist/types/features/build/legacy-constants.d.ts +0 -8
- package/dist/types/features/build/logger/index.d.ts +0 -2
- package/dist/types/features/build/logger/logText.d.ts +0 -39
- package/dist/types/features/build/logger/loggerManager.d.ts +0 -40
- package/dist/types/features/build/normalize.d.ts +0 -19
- package/dist/types/features/build/types.d.ts +0 -15
- package/dist/types/features/build/utils.d.ts +0 -36
- package/dist/types/features/dev/index.d.ts +0 -9
- package/dist/types/hooks/build.d.ts +0 -46
- package/dist/types/hooks/dev.d.ts +0 -20
- package/dist/types/hooks/index.d.ts +0 -30
- package/dist/types/schema/build-config.d.ts +0 -205
- package/dist/types/schema/index.d.ts +0 -217
- package/dist/types/schema/output.d.ts +0 -215
- package/dist/types/schema/source.d.ts +0 -6
- package/dist/types/schema/tools.d.ts +0 -6
- package/dist/types/schema/types.d.ts +0 -45
- package/dist/types/types.d.ts +0 -51
- package/dist/types/utils/babel.d.ts +0 -8
- package/dist/types/utils/color.d.ts +0 -2
- package/dist/types/utils/constants.d.ts +0 -2
- package/dist/types/utils/copy.d.ts +0 -5
- package/dist/types/utils/init-env.d.ts +0 -21
- package/dist/types/utils/json.d.ts +0 -4
- package/dist/types/utils/language.d.ts +0 -1
- package/dist/types/utils/logger.d.ts +0 -58
- package/dist/types/utils/readline.d.ts +0 -9
- package/dist/types/utils/tspaths-transform/constants.d.ts +0 -1
- package/dist/types/utils/tspaths-transform/utils.d.ts +0 -4
- package/dist/types/utils/valide.d.ts +0 -12
- package/types.d.ts +0 -1
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
-
import { chalk } from '@modern-js/utils';
|
|
3
|
-
export const colors = {
|
|
4
|
-
title: chalk.rgb(218, 152, 92)
|
|
5
|
-
};
|
|
6
|
-
export const clearFlag = '\x1Bc';
|
|
7
|
-
export const logTemplate = (title, messageStack, {
|
|
8
|
-
noBottomBorder: _noBottomBorder = false,
|
|
9
|
-
bottomBorderText: _bottomBorderText = '',
|
|
10
|
-
noLeftBorder: _noLeftBorder = false,
|
|
11
|
-
leftBorder: _leftBorder = '',
|
|
12
|
-
contentColor: _contentColor = s => s
|
|
13
|
-
} = {}) => {
|
|
14
|
-
const maxLength = Infinity; // TODO: 考虑后面是否提供该参数
|
|
15
|
-
const leftBorderFlag = _noLeftBorder ? '' : _leftBorder;
|
|
16
|
-
const messageFragments = messageStack.map(p => {
|
|
17
|
-
p.trim();
|
|
18
|
-
return `${leftBorderFlag}${p.replace(clearFlag, '')}`;
|
|
19
|
-
}) // 移除 clearFlag
|
|
20
|
-
.filter(s => s !== leftBorderFlag) // 过滤空字符串
|
|
21
|
-
.slice(0, maxLength); // 控制长度
|
|
22
|
-
const template = `${colors.title(title)}:
|
|
23
|
-
${_contentColor(messageFragments.join(''))}${_noBottomBorder ? '' : `\n${_bottomBorderText}`}`;
|
|
24
|
-
return template;
|
|
25
|
-
};
|
|
26
|
-
// 处理Log内容如何展示
|
|
27
|
-
export class LoggerText {
|
|
28
|
-
constructor(option) {
|
|
29
|
-
_defineProperty(this, "messages", void 0);
|
|
30
|
-
_defineProperty(this, "hasErrorMessage", void 0);
|
|
31
|
-
_defineProperty(this, "option", void 0);
|
|
32
|
-
this.messages = [];
|
|
33
|
-
this.option = option;
|
|
34
|
-
this.hasErrorMessage = false;
|
|
35
|
-
}
|
|
36
|
-
append(message) {
|
|
37
|
-
if (message.includes(clearFlag)) {
|
|
38
|
-
this.messages = [];
|
|
39
|
-
}
|
|
40
|
-
this.messages.push(message);
|
|
41
|
-
}
|
|
42
|
-
errorHappen() {
|
|
43
|
-
this.hasErrorMessage = true;
|
|
44
|
-
}
|
|
45
|
-
hasMessages() {
|
|
46
|
-
return this.messages.length > 0;
|
|
47
|
-
}
|
|
48
|
-
get value() {
|
|
49
|
-
const {
|
|
50
|
-
title,
|
|
51
|
-
contentConfig
|
|
52
|
-
} = this.option;
|
|
53
|
-
const messages = [...new Set(this.messages)];
|
|
54
|
-
return logTemplate(title, messages, contentConfig);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
let _ = t => t,
|
|
2
|
-
_t;
|
|
3
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
4
|
-
/**
|
|
5
|
-
* 1. 注册构建任务
|
|
6
|
-
* 2. 监听各个构建任务进程中的信息:process.stdout.on('data' | 'error')
|
|
7
|
-
* 3. 分别输出内容
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import EventEmitter from 'events';
|
|
11
|
-
import { chalk, Import } from '@modern-js/utils';
|
|
12
|
-
const logText = Import.lazy('./logText', require);
|
|
13
|
-
const readline = Import.lazy('../../../utils/readline', require);
|
|
14
|
-
export class LoggerManager extends EventEmitter {
|
|
15
|
-
constructor() {
|
|
16
|
-
super();
|
|
17
|
-
_defineProperty(this, "_compilering", void 0);
|
|
18
|
-
_defineProperty(this, "_listeners", void 0);
|
|
19
|
-
this._compilering = false;
|
|
20
|
-
this._listeners = [];
|
|
21
|
-
}
|
|
22
|
-
createLoggerText(option) {
|
|
23
|
-
return new logText.LoggerText(option);
|
|
24
|
-
}
|
|
25
|
-
addStdout(loggerText, stdout, config = {}) {
|
|
26
|
-
const {
|
|
27
|
-
event = {
|
|
28
|
-
data: true,
|
|
29
|
-
error: true
|
|
30
|
-
},
|
|
31
|
-
colors = {
|
|
32
|
-
data: chalk.green,
|
|
33
|
-
error: chalk.red,
|
|
34
|
-
warning: chalk.yellow
|
|
35
|
-
}
|
|
36
|
-
} = config;
|
|
37
|
-
if (event.data) {
|
|
38
|
-
stdout === null || stdout === void 0 ? void 0 : stdout.on('data', chunk => {
|
|
39
|
-
const data = chunk.toString();
|
|
40
|
-
const content = colors.data ? colors.data(data) : chalk.green(data);
|
|
41
|
-
loggerText.append(content);
|
|
42
|
-
this.emit('data');
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
if (event.error) {
|
|
46
|
-
stdout === null || stdout === void 0 ? void 0 : stdout.on('error', error => {
|
|
47
|
-
console.info('error');
|
|
48
|
-
const data = error.message;
|
|
49
|
-
const content = colors.error ? colors.error(data) : chalk.red(data);
|
|
50
|
-
loggerText.append(content);
|
|
51
|
-
loggerText.errorHappen();
|
|
52
|
-
this.emit('data');
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
this._listeners.push(stdout);
|
|
56
|
-
}
|
|
57
|
-
addStderr(loggerText, stderr, color = chalk.red) {
|
|
58
|
-
stderr === null || stderr === void 0 ? void 0 : stderr.on('data', chunk => {
|
|
59
|
-
const data = chunk.toString();
|
|
60
|
-
loggerText.append(color(data));
|
|
61
|
-
loggerText.errorHappen();
|
|
62
|
-
this.emit('data');
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
showCompiling() {
|
|
66
|
-
if (!this._compilering) {
|
|
67
|
-
this._compilering = true;
|
|
68
|
-
console.info(chalk.green(_t || (_t = _`Compiling in progress...`)));
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
disappearCompiling() {
|
|
72
|
-
if (this._compilering) {
|
|
73
|
-
readline.ReadlineUtils.clearLine(process.stdout);
|
|
74
|
-
this._compilering = false;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
listenDateAndShow(logTexts
|
|
78
|
-
// stdout: NodeJS.WriteStream & {
|
|
79
|
-
// fd: 1;
|
|
80
|
-
// } = process.stdout,
|
|
81
|
-
) {
|
|
82
|
-
this.on('data', () => {
|
|
83
|
-
this.disappearCompiling();
|
|
84
|
-
const content = logTexts.map(logtext => logtext.value).join('');
|
|
85
|
-
// 每次更新,使用新的内容覆盖旧的内容,有几率出现内容错乱问题
|
|
86
|
-
console.info(content);
|
|
87
|
-
});
|
|
88
|
-
return () => {
|
|
89
|
-
// eslint-disable-next-line no-process-exit
|
|
90
|
-
process.exit(0);
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
}
|
|
@@ -1,277 +0,0 @@
|
|
|
1
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
3
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
4
|
-
/* eslint-disable max-lines */
|
|
5
|
-
import { Import, lodash } from '@modern-js/utils';
|
|
6
|
-
import { mergeWith } from '@modern-js/utils/lodash';
|
|
7
|
-
import { cliTsConfigDefaultValue } from "../../utils/constants";
|
|
8
|
-
const constants = Import.lazy('./constants', require);
|
|
9
|
-
const legacyConstants = Import.lazy('./legacy-constants', require);
|
|
10
|
-
export const getNormalizeModuleConfigByPackageModeAndFileds = (api, buildFeatOption) => {
|
|
11
|
-
const {
|
|
12
|
-
output: {
|
|
13
|
-
packageMode,
|
|
14
|
-
packageFields,
|
|
15
|
-
disableTsChecker,
|
|
16
|
-
importStyle
|
|
17
|
-
}
|
|
18
|
-
} = api.useResolvedConfigContext();
|
|
19
|
-
let configs = [];
|
|
20
|
-
if (buildFeatOption.styleOnly) {
|
|
21
|
-
configs.push({
|
|
22
|
-
buildType: 'bundleless',
|
|
23
|
-
outputPath: './js/styles',
|
|
24
|
-
bundlelessOptions: {
|
|
25
|
-
sourceDir: './src',
|
|
26
|
-
style: {
|
|
27
|
-
compileMode: importStyle === 'source-code' ? 'only-source-code' : 'all'
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
configs.push({
|
|
32
|
-
buildType: 'bundleless',
|
|
33
|
-
outputPath: './styles',
|
|
34
|
-
bundlelessOptions: {
|
|
35
|
-
sourceDir: './styles',
|
|
36
|
-
style: {
|
|
37
|
-
compileMode: 'only-compiled-code'
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
return configs;
|
|
42
|
-
}
|
|
43
|
-
const commonConfig = {
|
|
44
|
-
buildType: 'bundleless',
|
|
45
|
-
bundlelessOptions: {
|
|
46
|
-
sourceDir: './src',
|
|
47
|
-
style: {
|
|
48
|
-
path: '../styles',
|
|
49
|
-
compileMode: false
|
|
50
|
-
},
|
|
51
|
-
static: {
|
|
52
|
-
path: '../styles'
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
outputPath: './'
|
|
56
|
-
};
|
|
57
|
-
commonConfig.tsconfig = getFinalTsconfig(commonConfig, buildFeatOption);
|
|
58
|
-
if (!packageFields || typeof packageFields === 'object' && Object.keys(packageFields).length === 0) {
|
|
59
|
-
const buildConfigs = legacyConstants.PACKAGE_MODES[packageMode || legacyConstants.DEFAULT_PACKAGE_MODE];
|
|
60
|
-
configs = buildConfigs.map(config => lodash.mergeWith({}, commonConfig, config));
|
|
61
|
-
} else {
|
|
62
|
-
const getConfigsByJsSyntaxType = (js, outputPath) => {
|
|
63
|
-
if (js === 'CJS+ES6') {
|
|
64
|
-
return lodash.mergeWith({}, commonConfig, {
|
|
65
|
-
format: 'cjs',
|
|
66
|
-
target: 'es6',
|
|
67
|
-
outputPath
|
|
68
|
-
});
|
|
69
|
-
} else if (js === 'ESM+ES5') {
|
|
70
|
-
return lodash.mergeWith({}, commonConfig, {
|
|
71
|
-
format: 'esm',
|
|
72
|
-
target: 'es5',
|
|
73
|
-
outputPath
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
return lodash.mergeWith({}, commonConfig, {
|
|
77
|
-
format: 'esm',
|
|
78
|
-
target: 'es6',
|
|
79
|
-
outputPath
|
|
80
|
-
});
|
|
81
|
-
};
|
|
82
|
-
if (!packageFields['jsnext:modern'] && !packageFields.main && !packageFields.module) {
|
|
83
|
-
throw new Error(`Unrecognized ${JSON.stringify(packageFields)} configuration, please use keys: 'modern, main, jupiter:modern' and use values: 'CJS+ES6, ESM+ES5, ESM+ES6'`);
|
|
84
|
-
}
|
|
85
|
-
// The fields configured in packageFields correspond to the main, module, and jsnext:modern fields on package.json,
|
|
86
|
-
// and can also be used on package.json exports field.
|
|
87
|
-
if (packageFields['jsnext:modern']) {
|
|
88
|
-
configs.push(getConfigsByJsSyntaxType(packageFields['jsnext:modern'], 'js/modern'));
|
|
89
|
-
}
|
|
90
|
-
if (packageFields.main) {
|
|
91
|
-
configs.push(getConfigsByJsSyntaxType(packageFields.main, 'js/node'));
|
|
92
|
-
}
|
|
93
|
-
if (packageFields.module) {
|
|
94
|
-
configs.push(getConfigsByJsSyntaxType(packageFields.module, 'js/treeshaking'));
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
if (configs.length > 0) {
|
|
98
|
-
const firstConfig = configs[0];
|
|
99
|
-
firstConfig.bundlelessOptions = lodash.mergeWith({}, firstConfig.bundlelessOptions, {
|
|
100
|
-
style: {
|
|
101
|
-
compileMode: importStyle === 'source-code' ? 'only-source-code' : 'all'
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// [compatibe mode]: dts gen
|
|
107
|
-
if (buildFeatOption.legacyTsc && !disableTsChecker) {
|
|
108
|
-
configs.push({
|
|
109
|
-
buildType: 'bundleless',
|
|
110
|
-
outputPath: './types',
|
|
111
|
-
enableDts: true,
|
|
112
|
-
dtsOnly: true
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
configs.push({
|
|
116
|
-
buildType: 'bundleless',
|
|
117
|
-
outputPath: './styles',
|
|
118
|
-
bundlelessOptions: {
|
|
119
|
-
sourceDir: './styles',
|
|
120
|
-
style: {
|
|
121
|
-
compileMode: 'only-compiled-code'
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
return configs;
|
|
126
|
-
};
|
|
127
|
-
export const getFinalTsconfig = (config, buildFeatOption) => {
|
|
128
|
-
var _config$tsconfig;
|
|
129
|
-
// cli tsconfig option > buildPreset tsconfig option
|
|
130
|
-
|
|
131
|
-
// Since tsconfig configuration has default values,
|
|
132
|
-
// compare the two to see if the user is configured with cli tsconfig
|
|
133
|
-
if (buildFeatOption.tsconfigName !== cliTsConfigDefaultValue) {
|
|
134
|
-
// TODO: transform tsconfig to absPath
|
|
135
|
-
return buildFeatOption.tsconfigName;
|
|
136
|
-
}
|
|
137
|
-
return (_config$tsconfig = config.tsconfig) !== null && _config$tsconfig !== void 0 ? _config$tsconfig : './tsconfig.json';
|
|
138
|
-
};
|
|
139
|
-
export const getFinalDts = (config, buildFeatOption) => {
|
|
140
|
-
var _config$enableDts;
|
|
141
|
-
// is js project, should return false
|
|
142
|
-
if (!buildFeatOption.isTsProject) {
|
|
143
|
-
return false;
|
|
144
|
-
}
|
|
145
|
-
// when `build --dts`, then all build tasks`s enableDts is true
|
|
146
|
-
if (buildFeatOption.enableDtsGen) {
|
|
147
|
-
return true;
|
|
148
|
-
}
|
|
149
|
-
return (_config$enableDts = config.enableDts) !== null && _config$enableDts !== void 0 ? _config$enableDts : false;
|
|
150
|
-
};
|
|
151
|
-
export const getSourceMap = (config, buildType, api) => {
|
|
152
|
-
// TODO: remove
|
|
153
|
-
const {
|
|
154
|
-
output: {
|
|
155
|
-
disableSourceMap
|
|
156
|
-
}
|
|
157
|
-
} = api.useResolvedConfigContext();
|
|
158
|
-
if (disableSourceMap) {
|
|
159
|
-
return false;
|
|
160
|
-
}
|
|
161
|
-
if (config.sourceMap !== undefined) {
|
|
162
|
-
return config.sourceMap;
|
|
163
|
-
}
|
|
164
|
-
return buildType === 'bundle';
|
|
165
|
-
};
|
|
166
|
-
export const normalizeBuildConfig = (context, buildConfig, deps = []) => {
|
|
167
|
-
const {
|
|
168
|
-
buildFeatOption,
|
|
169
|
-
api
|
|
170
|
-
} = context;
|
|
171
|
-
const configArray = Array.isArray(buildConfig) ? buildConfig : [buildConfig];
|
|
172
|
-
const normalizedModule = configArray.map(config => {
|
|
173
|
-
var _config$format, _config$target, _bundleOptions$skipDe, _bundleOptions$minify, _bundleOptions$splitt, _config$outputPath, _config$dtsOnly;
|
|
174
|
-
const format = (_config$format = config.format) !== null && _config$format !== void 0 ? _config$format : 'cjs';
|
|
175
|
-
const target = (_config$target = config.target) !== null && _config$target !== void 0 ? _config$target : 'esnext';
|
|
176
|
-
const {
|
|
177
|
-
bundleOptions
|
|
178
|
-
} = config;
|
|
179
|
-
const skipDeps = (_bundleOptions$skipDe = bundleOptions === null || bundleOptions === void 0 ? void 0 : bundleOptions.skipDeps) !== null && _bundleOptions$skipDe !== void 0 ? _bundleOptions$skipDe : true;
|
|
180
|
-
const externals = skipDeps === false ? (bundleOptions === null || bundleOptions === void 0 ? void 0 : bundleOptions.externals) || [] : [...deps.map(dep => new RegExp(`^${dep}($|\\/|\\\\)`)), ...((bundleOptions === null || bundleOptions === void 0 ? void 0 : bundleOptions.externals) || [])];
|
|
181
|
-
const normalizedBundleOption = _objectSpread(_objectSpread({}, bundleOptions), {}, {
|
|
182
|
-
entry: (bundleOptions === null || bundleOptions === void 0 ? void 0 : bundleOptions.entry) || {
|
|
183
|
-
index: `src/index.${buildFeatOption.isTsProject ? 'ts' : 'js'}`
|
|
184
|
-
},
|
|
185
|
-
platform: (bundleOptions === null || bundleOptions === void 0 ? void 0 : bundleOptions.platform) || 'node',
|
|
186
|
-
minify: (_bundleOptions$minify = bundleOptions === null || bundleOptions === void 0 ? void 0 : bundleOptions.minify) !== null && _bundleOptions$minify !== void 0 ? _bundleOptions$minify : false,
|
|
187
|
-
externals,
|
|
188
|
-
splitting: (_bundleOptions$splitt = bundleOptions === null || bundleOptions === void 0 ? void 0 : bundleOptions.splitting) !== null && _bundleOptions$splitt !== void 0 ? _bundleOptions$splitt : false,
|
|
189
|
-
skipDeps
|
|
190
|
-
});
|
|
191
|
-
const normalizedBundlelessOptions = mergeWith({}, {
|
|
192
|
-
sourceDir: './src',
|
|
193
|
-
style: {
|
|
194
|
-
compileMode: 'all',
|
|
195
|
-
path: './'
|
|
196
|
-
},
|
|
197
|
-
static: {
|
|
198
|
-
path: './'
|
|
199
|
-
}
|
|
200
|
-
}, config.bundlelessOptions);
|
|
201
|
-
const watch = buildFeatOption.enableWatchMode || false;
|
|
202
|
-
const tsconfig = getFinalTsconfig(config, buildFeatOption);
|
|
203
|
-
const enableDts = getFinalDts(config, buildFeatOption);
|
|
204
|
-
const outputPath = (_config$outputPath = config.outputPath) !== null && _config$outputPath !== void 0 ? _config$outputPath : './';
|
|
205
|
-
const sourceMap = getSourceMap(config, config.buildType, api);
|
|
206
|
-
const dtsOnly = (_config$dtsOnly = config.dtsOnly) !== null && _config$dtsOnly !== void 0 ? _config$dtsOnly : false;
|
|
207
|
-
const commmonConfig = {
|
|
208
|
-
format,
|
|
209
|
-
target,
|
|
210
|
-
watch,
|
|
211
|
-
tsconfig,
|
|
212
|
-
enableDts,
|
|
213
|
-
outputPath,
|
|
214
|
-
dtsOnly,
|
|
215
|
-
sourceMap
|
|
216
|
-
};
|
|
217
|
-
if (!buildFeatOption.isTsProject && (dtsOnly || enableDts)) {
|
|
218
|
-
console.warn('[WARN] dtsOnly、enableDts 配置仅在 Ts 项目下生效');
|
|
219
|
-
} else if (buildFeatOption.isTsProject && dtsOnly && !enableDts) {
|
|
220
|
-
console.warn('[WARN] dtsOnly 配置仅在 enableDts 为 true 的时候生效. 请检查当前的 dtsOnly、enableDts 是否配置正确');
|
|
221
|
-
}
|
|
222
|
-
if (config.buildType === 'bundle') {
|
|
223
|
-
return _objectSpread(_objectSpread({}, commmonConfig), {}, {
|
|
224
|
-
buildType: 'bundle',
|
|
225
|
-
bundleOptions: normalizedBundleOption
|
|
226
|
-
});
|
|
227
|
-
} else {
|
|
228
|
-
return _objectSpread(_objectSpread({}, commmonConfig), {}, {
|
|
229
|
-
buildType: 'bundleless',
|
|
230
|
-
bundlelessOptions: normalizedBundlelessOptions
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
});
|
|
234
|
-
return normalizedModule;
|
|
235
|
-
};
|
|
236
|
-
export const normalizeModuleConfig = context => {
|
|
237
|
-
const {
|
|
238
|
-
buildFeatOption,
|
|
239
|
-
api,
|
|
240
|
-
deps
|
|
241
|
-
} = context;
|
|
242
|
-
const {
|
|
243
|
-
output: {
|
|
244
|
-
buildConfig,
|
|
245
|
-
buildPreset
|
|
246
|
-
}
|
|
247
|
-
} = api.useResolvedConfigContext();
|
|
248
|
-
|
|
249
|
-
// buildConfig is the most important.
|
|
250
|
-
if (buildConfig) {
|
|
251
|
-
return normalizeBuildConfig(context, buildConfig, deps);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
// buildPreset is the second important. It can be used when buildConfig is not defined.
|
|
255
|
-
// buildPreset -> buildConfig
|
|
256
|
-
if (buildPreset) {
|
|
257
|
-
const {
|
|
258
|
-
unPresetConfigs,
|
|
259
|
-
unPresetWithTargetConfigs
|
|
260
|
-
} = constants;
|
|
261
|
-
if (unPresetConfigs[buildPreset]) {
|
|
262
|
-
return normalizeBuildConfig(context, unPresetConfigs[buildPreset], deps);
|
|
263
|
-
} else if (unPresetWithTargetConfigs[buildPreset]) {
|
|
264
|
-
return normalizeBuildConfig(context, unPresetWithTargetConfigs[buildPreset], deps);
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
// If the buildPreset is not found, then it is used 'npm-library'
|
|
268
|
-
// TODO: Warning: The buildPreset 'npm-library' is not supported.
|
|
269
|
-
return normalizeBuildConfig(context, unPresetConfigs['npm-library'], deps);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
// If the user does not configure buildConfig and buildPreset,
|
|
273
|
-
// the configuration is generated based on packageMode and packageField
|
|
274
|
-
const legacyBuildConfig = getNormalizeModuleConfigByPackageModeAndFileds(api, buildFeatOption);
|
|
275
|
-
return normalizeBuildConfig(context, legacyBuildConfig, deps);
|
|
276
|
-
};
|
|
277
|
-
/* eslint-enable max-lines */
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
-
import * as os from 'os';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import { chalk, Import, fs } from '@modern-js/utils';
|
|
5
|
-
const constants = Import.lazy('./constants', require);
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* 处理日志信息
|
|
9
|
-
*/
|
|
10
|
-
export class LogStack {
|
|
11
|
-
constructor() {
|
|
12
|
-
_defineProperty(this, "_codeLogStack", void 0);
|
|
13
|
-
this._codeLogStack = [];
|
|
14
|
-
}
|
|
15
|
-
update(latestLog, {
|
|
16
|
-
splitEOL = false
|
|
17
|
-
} = {}) {
|
|
18
|
-
if (splitEOL) {
|
|
19
|
-
latestLog.split(os.EOL).forEach(log => {
|
|
20
|
-
this._codeLogStack.unshift(log.trim());
|
|
21
|
-
});
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
this._codeLogStack.unshift(latestLog.trim());
|
|
25
|
-
}
|
|
26
|
-
clear() {
|
|
27
|
-
this._codeLogStack = [];
|
|
28
|
-
}
|
|
29
|
-
get value() {
|
|
30
|
-
return [...new Set(this._codeLogStack)];
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
export const logTemplate = (title, messageStack, maxLength, {
|
|
34
|
-
noBottomBorder: _noBottomBorder = false,
|
|
35
|
-
bottomBorderText: _bottomBorderText = '',
|
|
36
|
-
noLeftBorder: _noLeftBorder = false,
|
|
37
|
-
leftBorder: _leftBorder = '│',
|
|
38
|
-
contentColor: _contentColor = s => s
|
|
39
|
-
} = {}) => {
|
|
40
|
-
const leftBorderFlag = _noLeftBorder ? '' : _leftBorder;
|
|
41
|
-
const messageFragments = messageStack.map(p => {
|
|
42
|
-
p.trim();
|
|
43
|
-
return `${leftBorderFlag}${p.replace(constants.clearFlag, '')}`;
|
|
44
|
-
}) // 移除 clearFlag
|
|
45
|
-
.slice(0, maxLength) // 控制长度
|
|
46
|
-
.filter(s => s !== leftBorderFlag) // 过滤空字符串
|
|
47
|
-
.reverse(); // 调换顺序,最新的消息在最后面
|
|
48
|
-
const template = `${title}:
|
|
49
|
-
${_contentColor(messageFragments.join(os.EOL))}${_noBottomBorder ? '' : `\n${_bottomBorderText}`}`;
|
|
50
|
-
return template;
|
|
51
|
-
};
|
|
52
|
-
export let SectionTitleStatus;
|
|
53
|
-
(function (SectionTitleStatus) {
|
|
54
|
-
SectionTitleStatus[SectionTitleStatus["Success"] = 0] = "Success";
|
|
55
|
-
SectionTitleStatus[SectionTitleStatus["Fail"] = 1] = "Fail";
|
|
56
|
-
SectionTitleStatus[SectionTitleStatus["Log"] = 2] = "Log";
|
|
57
|
-
})(SectionTitleStatus || (SectionTitleStatus = {}));
|
|
58
|
-
export const watchSectionTitle = (str, status) => {
|
|
59
|
-
if (status === SectionTitleStatus.Success) {
|
|
60
|
-
return `${chalk.bgWhite.gray.underline(str)} ${chalk.green.underline('Successful')}`;
|
|
61
|
-
} else if (status === SectionTitleStatus.Fail) {
|
|
62
|
-
return `${chalk.bgWhite.gray.underline(str)} ${chalk.red.underline('Build Failed')}`;
|
|
63
|
-
}
|
|
64
|
-
return `${chalk.bgWhite.gray.underline(str)} ${chalk.blue.underline('Log')}`;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
68
|
-
export const getPostcssOption = (...args) => {
|
|
69
|
-
// const postcssOption: any = cssConfig.getPostcssConfig(
|
|
70
|
-
// appDirectory,
|
|
71
|
-
// modernConfig,
|
|
72
|
-
// false,
|
|
73
|
-
// );
|
|
74
|
-
return {
|
|
75
|
-
plugins: [],
|
|
76
|
-
enableSourceMap: false,
|
|
77
|
-
// plugins: postcssOption?.postcssOptions?.plugins || [],
|
|
78
|
-
// enableSourceMap: (postcssOption as any)?.sourceMap || false,
|
|
79
|
-
options: {}
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
|
-
export const getAllDeps = appDirectory => {
|
|
83
|
-
try {
|
|
84
|
-
const json = JSON.parse(fs.readFileSync(path.resolve(appDirectory, './package.json'), 'utf8'));
|
|
85
|
-
|
|
86
|
-
// return json[packageJsonConfig ?? PACKAGE_JSON_CONFIG_NAME] as T | undefined;
|
|
87
|
-
return [...Object.keys(json.dependencies || {}), ...Object.keys(json.devDependencies || {}), ...Object.keys(json.peerDependencies || {})];
|
|
88
|
-
} catch (e) {
|
|
89
|
-
console.warn('[WARN] package.json is broken');
|
|
90
|
-
return [];
|
|
91
|
-
}
|
|
92
|
-
};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { chalk, Import, inquirer } from '@modern-js/utils';
|
|
2
|
-
const color = Import.lazy('../../utils/color', require);
|
|
3
|
-
export const showMenu = async (api, config) => {
|
|
4
|
-
const runners = api.useHookRunners();
|
|
5
|
-
const metas = await runners.moduleToolsMenu(undefined);
|
|
6
|
-
if (metas.length <= 0) {
|
|
7
|
-
console.info(chalk.yellow('No runnable development features found.\nYou can use the `new` command to enable the development features'));
|
|
8
|
-
// eslint-disable-next-line no-process-exit
|
|
9
|
-
process.exit(0);
|
|
10
|
-
}
|
|
11
|
-
const menuMessage = color.devMenuTitle('Select the debug mode:');
|
|
12
|
-
const {
|
|
13
|
-
type
|
|
14
|
-
} = await inquirer.prompt([{
|
|
15
|
-
name: 'type',
|
|
16
|
-
message: menuMessage,
|
|
17
|
-
type: 'list',
|
|
18
|
-
choices: metas
|
|
19
|
-
}]);
|
|
20
|
-
const devMeta = metas.find(meta => meta.value === type);
|
|
21
|
-
if (devMeta) {
|
|
22
|
-
await devMeta.runTask(config);
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
export const devStorybook = async (api, config) => {
|
|
26
|
-
const runners = api.useHookRunners();
|
|
27
|
-
const metas = await runners.moduleToolsMenu(undefined);
|
|
28
|
-
const findStorybook = metas.find(meta => meta.value === 'storybook');
|
|
29
|
-
if (findStorybook) {
|
|
30
|
-
await findStorybook.runTask(config);
|
|
31
|
-
} else {
|
|
32
|
-
console.info(chalk.yellow('No development features found.\nYou can use the `new` command to enable the development features'));
|
|
33
|
-
// eslint-disable-next-line no-process-exit
|
|
34
|
-
process.exit(0);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
export const runSubCmd = async (api, subCmd, config) => {
|
|
38
|
-
const runners = api.useHookRunners();
|
|
39
|
-
const metas = await runners.moduleToolsMenu(undefined);
|
|
40
|
-
const devMeta = metas.find(meta => meta.value === subCmd || Array.isArray(meta.aliasValues) && meta.aliasValues.includes(subCmd));
|
|
41
|
-
if (devMeta) {
|
|
42
|
-
await devMeta.runTask(config);
|
|
43
|
-
} else {
|
|
44
|
-
// eslint-disable-next-line no-process-exit
|
|
45
|
-
process.exit(0);
|
|
46
|
-
}
|
|
47
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { createParallelWorkflow, createAsyncPipeline } from '@modern-js/plugin';
|
|
2
|
-
import { registerHook } from '@modern-js/core';
|
|
3
|
-
export const platformBuild = createParallelWorkflow();
|
|
4
|
-
export const moduleLessConfig = createAsyncPipeline();
|
|
5
|
-
export const moduleSassConfig = createAsyncPipeline();
|
|
6
|
-
export const moduleTailwindConfig = createAsyncPipeline();
|
|
7
|
-
export const buildHooks = {
|
|
8
|
-
platformBuild,
|
|
9
|
-
moduleLessConfig,
|
|
10
|
-
moduleSassConfig,
|
|
11
|
-
moduleTailwindConfig
|
|
12
|
-
};
|
|
13
|
-
export const lifecycle = () => {
|
|
14
|
-
registerHook({
|
|
15
|
-
moduleLessConfig,
|
|
16
|
-
moduleSassConfig,
|
|
17
|
-
moduleTailwindConfig,
|
|
18
|
-
platformBuild
|
|
19
|
-
});
|
|
20
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { createParallelWorkflow, createAsyncWorkflow } from '@modern-js/plugin';
|
|
2
|
-
import { registerHook } from '@modern-js/core';
|
|
3
|
-
export const moduleToolsMenu = createParallelWorkflow();
|
|
4
|
-
export const afterDev = createAsyncWorkflow();
|
|
5
|
-
export const devHooks = {
|
|
6
|
-
moduleToolsMenu,
|
|
7
|
-
afterDev
|
|
8
|
-
};
|
|
9
|
-
export const lifecycle = () => {
|
|
10
|
-
registerHook({
|
|
11
|
-
moduleToolsMenu,
|
|
12
|
-
afterDev
|
|
13
|
-
});
|
|
14
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
3
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
4
|
-
import { createAsyncWaterfall } from '@modern-js/plugin';
|
|
5
|
-
import { buildHooks, lifecycle as buildLifeCycle } from "./build";
|
|
6
|
-
import { devHooks, lifecycle as devLifeCycle } from "./dev";
|
|
7
|
-
export { buildLifeCycle, devLifeCycle };
|
|
8
|
-
export const lifecycle = () => {
|
|
9
|
-
devLifeCycle();
|
|
10
|
-
buildLifeCycle();
|
|
11
|
-
};
|
|
12
|
-
export const addRuntimeExports = createAsyncWaterfall();
|
|
13
|
-
export const hooks = _objectSpread(_objectSpread(_objectSpread({}, buildHooks), devHooks), {}, {
|
|
14
|
-
addRuntimeExports
|
|
15
|
-
});
|
package/dist/js/modern/index.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { Import, fs } from '@modern-js/utils';
|
|
2
|
-
import ChangesetPlugin from '@modern-js/plugin-changeset';
|
|
3
|
-
import LintPlugin from '@modern-js/plugin-lint';
|
|
4
|
-
import { hooks } from "./hooks";
|
|
5
|
-
export * from "./types";
|
|
6
|
-
const upgradeModel = Import.lazy('@modern-js/upgrade', require);
|
|
7
|
-
const cli = Import.lazy('./cli', require);
|
|
8
|
-
const local = Import.lazy('./locale', require);
|
|
9
|
-
const schema = Import.lazy('./schema', require);
|
|
10
|
-
const lang = Import.lazy('./utils/language', require);
|
|
11
|
-
|
|
12
|
-
// export { defineConfig } from '@modern-js/core';
|
|
13
|
-
|
|
14
|
-
const isBuildMode = process.argv.slice(2)[0] === 'build';
|
|
15
|
-
export default (() => ({
|
|
16
|
-
name: '@modern-js/module-tools',
|
|
17
|
-
post: ['@modern-js/plugin-changeset'],
|
|
18
|
-
registerHook: hooks,
|
|
19
|
-
usePlugins: isBuildMode ? [] : [ChangesetPlugin(), LintPlugin()],
|
|
20
|
-
setup: api => {
|
|
21
|
-
const locale = lang.getLocaleLanguage();
|
|
22
|
-
local.i18n.changeLanguage({
|
|
23
|
-
locale
|
|
24
|
-
});
|
|
25
|
-
return {
|
|
26
|
-
// copy from @modern-js/app-tools/src/analyze/index.ts
|
|
27
|
-
async prepare() {
|
|
28
|
-
const appContext = api.useAppContext();
|
|
29
|
-
const hookRunners = api.useHookRunners();
|
|
30
|
-
try {
|
|
31
|
-
fs.emptydirSync(appContext.internalDirectory);
|
|
32
|
-
} catch (_unused) {
|
|
33
|
-
// FIXME:
|
|
34
|
-
}
|
|
35
|
-
await hookRunners.addRuntimeExports();
|
|
36
|
-
},
|
|
37
|
-
validateSchema() {
|
|
38
|
-
return schema.addSchema();
|
|
39
|
-
},
|
|
40
|
-
config() {
|
|
41
|
-
return {
|
|
42
|
-
source: {},
|
|
43
|
-
output: {
|
|
44
|
-
enableSourceMap: false,
|
|
45
|
-
jsPath: 'js'
|
|
46
|
-
},
|
|
47
|
-
tools: {}
|
|
48
|
-
};
|
|
49
|
-
},
|
|
50
|
-
commands({
|
|
51
|
-
program
|
|
52
|
-
}) {
|
|
53
|
-
cli.devCli(program, api);
|
|
54
|
-
cli.buildCli(program, api);
|
|
55
|
-
cli.newCli(program, locale);
|
|
56
|
-
upgradeModel.defineCommand(program.command('upgrade'));
|
|
57
|
-
|
|
58
|
-
// 便于其他插件辨别
|
|
59
|
-
program.$$libraryName = 'module-tools';
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
}));
|