@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,241 +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 * as path from 'path';
|
|
5
|
-
import { fs, glob, Import, watch as watcher, WatchChangeType, chalk, globby, slash } from '@modern-js/utils';
|
|
6
|
-
import { InternalBuildError } from "../error";
|
|
7
|
-
import { watchSectionTitle, SectionTitleStatus, getPostcssOption } from "../utils";
|
|
8
|
-
const compiler = Import.lazy('@modern-js/style-compiler', require);
|
|
9
|
-
export class StyleBuildError extends Error {
|
|
10
|
-
constructor(message, opts) {
|
|
11
|
-
super(message);
|
|
12
|
-
_defineProperty(this, "summary", void 0);
|
|
13
|
-
_defineProperty(this, "details", void 0);
|
|
14
|
-
Error.captureStackTrace(this, this.constructor);
|
|
15
|
-
this.summary = opts === null || opts === void 0 ? void 0 : opts.summary;
|
|
16
|
-
this.details = opts === null || opts === void 0 ? void 0 : opts.details;
|
|
17
|
-
}
|
|
18
|
-
toString() {
|
|
19
|
-
return this.formatError().join('\n');
|
|
20
|
-
}
|
|
21
|
-
formatError() {
|
|
22
|
-
const msgs = [];
|
|
23
|
-
const {
|
|
24
|
-
summary,
|
|
25
|
-
details = []
|
|
26
|
-
} = this;
|
|
27
|
-
msgs.push(chalk.red.bold(summary));
|
|
28
|
-
for (const detail of details) {
|
|
29
|
-
if (detail.error) {
|
|
30
|
-
msgs.push(detail.error);
|
|
31
|
-
msgs.push('\n');
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return msgs;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* when modern build, only throw Error or silent
|
|
40
|
-
* @param result
|
|
41
|
-
* @param context
|
|
42
|
-
*/
|
|
43
|
-
const generatorFileOrLogError = (result, context) => {
|
|
44
|
-
if (result.code === 0) {
|
|
45
|
-
for (const file of result.dists) {
|
|
46
|
-
fs.ensureFileSync(file.filename);
|
|
47
|
-
fs.writeFileSync(file.filename, file.content);
|
|
48
|
-
}
|
|
49
|
-
} else {
|
|
50
|
-
// for (const file of result.errors) {
|
|
51
|
-
// console.error(file.error);
|
|
52
|
-
// }
|
|
53
|
-
const styleError = new StyleBuildError('bundleless failed', {
|
|
54
|
-
summary: 'Style Compiler Failed',
|
|
55
|
-
details: result.errors
|
|
56
|
-
});
|
|
57
|
-
throw new InternalBuildError(styleError, _objectSpread({
|
|
58
|
-
buildType: 'bundleless'
|
|
59
|
-
}, context));
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
const generatorFileAndLog = (result, titleText) => {
|
|
63
|
-
if (result.code === 0) {
|
|
64
|
-
for (const file of result.dists) {
|
|
65
|
-
fs.ensureFileSync(file.filename);
|
|
66
|
-
fs.writeFileSync(file.filename, file.content);
|
|
67
|
-
}
|
|
68
|
-
console.info(watchSectionTitle(titleText, SectionTitleStatus.Success));
|
|
69
|
-
} else {
|
|
70
|
-
console.info(watchSectionTitle(titleText, SectionTitleStatus.Fail));
|
|
71
|
-
for (const file of result.errors) {
|
|
72
|
-
console.error(file.error);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
const copyOriginStyleFiles = ({
|
|
77
|
-
targetDir,
|
|
78
|
-
outputDir,
|
|
79
|
-
ignoreCSS: _ignoreCSS = false
|
|
80
|
-
}) => {
|
|
81
|
-
const styleFiles = glob.sync(`${targetDir}/**/*.{${_ignoreCSS ? '' : 'css,'}sass,scss,less}`);
|
|
82
|
-
if (styleFiles.length > 0) {
|
|
83
|
-
fs.ensureDirSync(outputDir);
|
|
84
|
-
}
|
|
85
|
-
for (const styleFile of styleFiles) {
|
|
86
|
-
const file = path.relative(targetDir, styleFile);
|
|
87
|
-
fs.ensureDirSync(path.dirname(path.join(outputDir, file)));
|
|
88
|
-
fs.copyFileSync(styleFile, path.join(outputDir, file));
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
export const runBuild = async option => {
|
|
92
|
-
const {
|
|
93
|
-
watch,
|
|
94
|
-
appDirectory,
|
|
95
|
-
srcDir,
|
|
96
|
-
outDir,
|
|
97
|
-
lessOption,
|
|
98
|
-
sassOption,
|
|
99
|
-
postcssOption
|
|
100
|
-
} = option;
|
|
101
|
-
if (watch) {
|
|
102
|
-
const srcStyleEmitter = compiler.styleCompiler({
|
|
103
|
-
watch: true,
|
|
104
|
-
projectDir: appDirectory,
|
|
105
|
-
stylesDir: srcDir,
|
|
106
|
-
outDir,
|
|
107
|
-
enableVirtualDist: true,
|
|
108
|
-
compilerOption: {
|
|
109
|
-
less: lessOption,
|
|
110
|
-
sass: sassOption,
|
|
111
|
-
postcss: postcssOption
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
return srcStyleEmitter;
|
|
115
|
-
} else {
|
|
116
|
-
const srcStyleResult = await compiler.styleCompiler({
|
|
117
|
-
projectDir: appDirectory,
|
|
118
|
-
stylesDir: srcDir,
|
|
119
|
-
outDir,
|
|
120
|
-
enableVirtualDist: true,
|
|
121
|
-
compilerOption: {
|
|
122
|
-
less: lessOption,
|
|
123
|
-
sass: sassOption,
|
|
124
|
-
postcss: postcssOption
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
return srcStyleResult;
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
export const styleFileSuffix = ['css', 'less', 'sass', 'scss'];
|
|
131
|
-
export const haveNotAnyStyles = async sourceDir => {
|
|
132
|
-
const files = await globby(slash(`${sourceDir}/**/*.{${styleFileSuffix.join(',')}}`));
|
|
133
|
-
return files.length === 0;
|
|
134
|
-
};
|
|
135
|
-
export const buildStyle = async (api, config) => {
|
|
136
|
-
var _style$path;
|
|
137
|
-
const modernConfig = api.useResolvedConfigContext();
|
|
138
|
-
const {
|
|
139
|
-
appDirectory
|
|
140
|
-
} = api.useAppContext();
|
|
141
|
-
const {
|
|
142
|
-
watch = false,
|
|
143
|
-
outputPath,
|
|
144
|
-
bundlelessOptions
|
|
145
|
-
} = config;
|
|
146
|
-
const {
|
|
147
|
-
style,
|
|
148
|
-
sourceDir
|
|
149
|
-
} = bundlelessOptions;
|
|
150
|
-
const {
|
|
151
|
-
output: {
|
|
152
|
-
path: distPath = 'dist'
|
|
153
|
-
}
|
|
154
|
-
} = modernConfig;
|
|
155
|
-
const titleText = `[Bundleless:Style:${sourceDir}]`;
|
|
156
|
-
if ((await haveNotAnyStyles(sourceDir)) || style.compileMode === false) {
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
const runner = api.useHookRunners();
|
|
160
|
-
const lessOption = await runner.moduleLessConfig({
|
|
161
|
-
modernConfig
|
|
162
|
-
}, {
|
|
163
|
-
onLast: async _ => undefined
|
|
164
|
-
});
|
|
165
|
-
const sassOption = await runner.moduleSassConfig({
|
|
166
|
-
modernConfig
|
|
167
|
-
}, {
|
|
168
|
-
onLast: async _ => undefined
|
|
169
|
-
});
|
|
170
|
-
const tailwindPlugin = await runner.moduleTailwindConfig({
|
|
171
|
-
modernConfig
|
|
172
|
-
}, {
|
|
173
|
-
onLast: async _ => undefined
|
|
174
|
-
});
|
|
175
|
-
const postcssOption = getPostcssOption(appDirectory, modernConfig);
|
|
176
|
-
if (tailwindPlugin) {
|
|
177
|
-
var _postcssOption$plugin;
|
|
178
|
-
(_postcssOption$plugin = postcssOption.plugins) === null || _postcssOption$plugin === void 0 ? void 0 : _postcssOption$plugin.push(tailwindPlugin);
|
|
179
|
-
}
|
|
180
|
-
const srcDir = path.resolve(appDirectory, sourceDir);
|
|
181
|
-
const outputDirToSrc = path.join(appDirectory, distPath, outputPath, (_style$path = style.path) !== null && _style$path !== void 0 ? _style$path : './');
|
|
182
|
-
if (style.compileMode === 'all' || style.compileMode === 'only-compiled-code') {
|
|
183
|
-
const result = await runBuild({
|
|
184
|
-
appDirectory,
|
|
185
|
-
srcDir,
|
|
186
|
-
watch,
|
|
187
|
-
outDir: outputDirToSrc,
|
|
188
|
-
lessOption,
|
|
189
|
-
sassOption,
|
|
190
|
-
postcssOption
|
|
191
|
-
});
|
|
192
|
-
if (watch) {
|
|
193
|
-
const emitter = result;
|
|
194
|
-
emitter.on(compiler.BuildWatchEvent.firstCompiler, result => {
|
|
195
|
-
generatorFileAndLog(result, titleText);
|
|
196
|
-
});
|
|
197
|
-
emitter.on(compiler.BuildWatchEvent.watchingCompiler, srcStyleResult => {
|
|
198
|
-
generatorFileAndLog(srcStyleResult, titleText);
|
|
199
|
-
});
|
|
200
|
-
await emitter.watch();
|
|
201
|
-
} else {
|
|
202
|
-
const srcStyleResult = result;
|
|
203
|
-
generatorFileOrLogError(srcStyleResult, {
|
|
204
|
-
target: config.target,
|
|
205
|
-
format: config.format
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
if (style.compileMode === 'all' || style.compileMode === 'only-source-code') {
|
|
210
|
-
if (watch) {
|
|
211
|
-
copyOriginStyleFiles({
|
|
212
|
-
targetDir: srcDir,
|
|
213
|
-
outputDir: outputDirToSrc,
|
|
214
|
-
ignoreCSS: style.compileMode === 'all'
|
|
215
|
-
});
|
|
216
|
-
console.info(watchSectionTitle(titleText, SectionTitleStatus.Success));
|
|
217
|
-
watcher(`${srcDir}/**/*.{css,less,sass,scss}`, ({
|
|
218
|
-
changeType,
|
|
219
|
-
changedFilePath
|
|
220
|
-
}) => {
|
|
221
|
-
if (changeType === WatchChangeType.UNLINK) {
|
|
222
|
-
const removeFile = path.normalize(`${outputDirToSrc}/${path.relative(srcDir, changedFilePath)}`);
|
|
223
|
-
fs.removeSync(removeFile);
|
|
224
|
-
} else {
|
|
225
|
-
copyOriginStyleFiles({
|
|
226
|
-
targetDir: srcDir,
|
|
227
|
-
outputDir: outputDirToSrc,
|
|
228
|
-
ignoreCSS: style.compileMode === 'all'
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
console.info(watchSectionTitle(titleText, SectionTitleStatus.Success));
|
|
232
|
-
});
|
|
233
|
-
} else {
|
|
234
|
-
copyOriginStyleFiles({
|
|
235
|
-
targetDir: srcDir,
|
|
236
|
-
outputDir: outputDirToSrc,
|
|
237
|
-
ignoreCSS: style.compileMode === 'all'
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
};
|
|
@@ -1,98 +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 { chalk } from '@modern-js/utils';
|
|
5
|
-
export const clearFlag = '\x1Bc';
|
|
6
|
-
export const buildingText = chalk.blue('Building...');
|
|
7
|
-
export const buildSuccessText = chalk.green('Build succeed');
|
|
8
|
-
export const buildFailText = chalk.red('Build Failed:');
|
|
9
|
-
export const targets = ['es5', 'es6', 'es2015', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext'];
|
|
10
|
-
export const npmLibraryPresetConfig = [{
|
|
11
|
-
format: 'cjs',
|
|
12
|
-
target: 'es6',
|
|
13
|
-
buildType: 'bundle',
|
|
14
|
-
outputPath: './lib'
|
|
15
|
-
}, {
|
|
16
|
-
format: 'esm',
|
|
17
|
-
target: 'es6',
|
|
18
|
-
buildType: 'bundle',
|
|
19
|
-
outputPath: './es'
|
|
20
|
-
}, {
|
|
21
|
-
buildType: 'bundle',
|
|
22
|
-
outputPath: './types',
|
|
23
|
-
enableDts: true,
|
|
24
|
-
dtsOnly: true
|
|
25
|
-
}];
|
|
26
|
-
export const npmLibraryWithUmdPresetConfig = [{
|
|
27
|
-
format: 'cjs',
|
|
28
|
-
target: 'es6',
|
|
29
|
-
buildType: 'bundle',
|
|
30
|
-
outputPath: './lib'
|
|
31
|
-
}, {
|
|
32
|
-
format: 'esm',
|
|
33
|
-
target: 'es6',
|
|
34
|
-
buildType: 'bundle',
|
|
35
|
-
outputPath: './es'
|
|
36
|
-
}, {
|
|
37
|
-
format: 'umd',
|
|
38
|
-
target: 'es6',
|
|
39
|
-
buildType: 'bundle',
|
|
40
|
-
outputPath: './umd'
|
|
41
|
-
}, {
|
|
42
|
-
buildType: 'bundle',
|
|
43
|
-
outputPath: './types',
|
|
44
|
-
enableDts: true,
|
|
45
|
-
dtsOnly: true
|
|
46
|
-
}];
|
|
47
|
-
export const npmComponentPresetConfig = [{
|
|
48
|
-
format: 'cjs',
|
|
49
|
-
target: 'es6',
|
|
50
|
-
buildType: 'bundleless',
|
|
51
|
-
outputPath: './lib'
|
|
52
|
-
}, {
|
|
53
|
-
format: 'esm',
|
|
54
|
-
target: 'es6',
|
|
55
|
-
buildType: 'bundleless',
|
|
56
|
-
outputPath: './es'
|
|
57
|
-
}, {
|
|
58
|
-
buildType: 'bundleless',
|
|
59
|
-
outputPath: './types',
|
|
60
|
-
enableDts: true,
|
|
61
|
-
dtsOnly: true
|
|
62
|
-
}];
|
|
63
|
-
export const npmComponentWithUmdPresetConfig = [{
|
|
64
|
-
format: 'cjs',
|
|
65
|
-
target: 'es6',
|
|
66
|
-
buildType: 'bundleless',
|
|
67
|
-
outputPath: './lib'
|
|
68
|
-
}, {
|
|
69
|
-
format: 'esm',
|
|
70
|
-
target: 'es6',
|
|
71
|
-
buildType: 'bundleless',
|
|
72
|
-
outputPath: './es'
|
|
73
|
-
}, {
|
|
74
|
-
format: 'umd',
|
|
75
|
-
target: 'es6',
|
|
76
|
-
buildType: 'bundle',
|
|
77
|
-
outputPath: './umd'
|
|
78
|
-
}, {
|
|
79
|
-
buildType: 'bundleless',
|
|
80
|
-
outputPath: './types',
|
|
81
|
-
enableDts: true,
|
|
82
|
-
dtsOnly: true
|
|
83
|
-
}];
|
|
84
|
-
export const unPresetConfigs = {
|
|
85
|
-
'npm-library': npmLibraryPresetConfig,
|
|
86
|
-
'npm-library-with-umd': npmLibraryWithUmdPresetConfig,
|
|
87
|
-
'npm-component': npmComponentPresetConfig,
|
|
88
|
-
'npm-component-with-umd': npmComponentWithUmdPresetConfig
|
|
89
|
-
};
|
|
90
|
-
export const unPresets = Object.keys(unPresetConfigs);
|
|
91
|
-
export const unPresetWithTargetConfigs = unPresets.reduce((o, presetStr) => {
|
|
92
|
-
const rets = targets.map(target => [`${presetStr}-${target}`.toLowerCase(), unPresetConfigs[presetStr].map(config => {
|
|
93
|
-
return _objectSpread(_objectSpread({}, config), {}, {
|
|
94
|
-
target
|
|
95
|
-
});
|
|
96
|
-
})]);
|
|
97
|
-
return _objectSpread(_objectSpread({}, o), Object.fromEntries(rets));
|
|
98
|
-
}, {});
|
|
@@ -1,127 +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 padSpaceWith = (str, targetL, opts = {}) => {
|
|
4
|
-
const {
|
|
5
|
-
endStr = '|',
|
|
6
|
-
style
|
|
7
|
-
} = opts;
|
|
8
|
-
const l = str.length;
|
|
9
|
-
const endStrL = endStr.length;
|
|
10
|
-
const resetL = targetL - l - endStrL;
|
|
11
|
-
|
|
12
|
-
// str is 'aaa', targetL is 4, result is 'aaa|'
|
|
13
|
-
if (resetL === 0) {
|
|
14
|
-
return (style ? style(str) : str) + endStr;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// str is 'aaa', targetL is 5, result is 'aaa |'
|
|
18
|
-
if (resetL > 0) {
|
|
19
|
-
const padStr = str.padEnd(targetL - 1, ' ');
|
|
20
|
-
if (style) {
|
|
21
|
-
return style(str) + padStr.replace(str, '') + endStr;
|
|
22
|
-
}
|
|
23
|
-
return padStr + endStr;
|
|
24
|
-
}
|
|
25
|
-
return str;
|
|
26
|
-
};
|
|
27
|
-
export class InternalBuildError extends Error {
|
|
28
|
-
constructor(e, opts) {
|
|
29
|
-
super(e.message);
|
|
30
|
-
_defineProperty(this, "buildType", void 0);
|
|
31
|
-
_defineProperty(this, "target", void 0);
|
|
32
|
-
_defineProperty(this, "format", void 0);
|
|
33
|
-
_defineProperty(this, "e", void 0);
|
|
34
|
-
Error.captureStackTrace(this, this.constructor);
|
|
35
|
-
this.e = e;
|
|
36
|
-
this.buildType = opts.buildType;
|
|
37
|
-
this.target = opts.target;
|
|
38
|
-
this.format = opts.format;
|
|
39
|
-
}
|
|
40
|
-
toString() {
|
|
41
|
-
return this.formatError().join('\n');
|
|
42
|
-
}
|
|
43
|
-
formatError() {
|
|
44
|
-
const msgs = [];
|
|
45
|
-
const {
|
|
46
|
-
e,
|
|
47
|
-
buildType,
|
|
48
|
-
target,
|
|
49
|
-
format
|
|
50
|
-
} = this;
|
|
51
|
-
const textL = 25;
|
|
52
|
-
const title = `│ ${padSpaceWith(`${buildType} failed:`, textL - 2, {
|
|
53
|
-
style: chalk.red.underline,
|
|
54
|
-
endStr: '│'
|
|
55
|
-
})}`;
|
|
56
|
-
const formatMsg = padSpaceWith(`│ - format is "${format}"`, textL, {
|
|
57
|
-
endStr: '│'
|
|
58
|
-
});
|
|
59
|
-
const targetMsg = padSpaceWith(`│ - target is "${target}"`, textL, {
|
|
60
|
-
endStr: '│'
|
|
61
|
-
});
|
|
62
|
-
const startLine = padSpaceWith('╭'.padEnd(textL - 1, '─'), textL, {
|
|
63
|
-
endStr: '╮'
|
|
64
|
-
});
|
|
65
|
-
const endLine = padSpaceWith('╰'.padEnd(textL - 1, '─'), textL, {
|
|
66
|
-
endStr: '╯'
|
|
67
|
-
});
|
|
68
|
-
msgs.push(startLine, title, formatMsg, targetMsg, endLine, chalk.blue.bold.underline(`\nDetailed Information: `));
|
|
69
|
-
msgs.push(e.toString());
|
|
70
|
-
msgs.push(e.stack || '');
|
|
71
|
-
return msgs;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
export class InternalDTSError extends Error {
|
|
75
|
-
constructor(e, opts) {
|
|
76
|
-
super(e.message);
|
|
77
|
-
_defineProperty(this, "buildType", void 0);
|
|
78
|
-
_defineProperty(this, "e", void 0);
|
|
79
|
-
Error.captureStackTrace(this, this.constructor);
|
|
80
|
-
this.e = e;
|
|
81
|
-
this.buildType = opts.buildType;
|
|
82
|
-
}
|
|
83
|
-
toString() {
|
|
84
|
-
return this.formatError().join('\n');
|
|
85
|
-
}
|
|
86
|
-
formatError() {
|
|
87
|
-
const msgs = [];
|
|
88
|
-
const {
|
|
89
|
-
e,
|
|
90
|
-
buildType
|
|
91
|
-
} = this;
|
|
92
|
-
msgs.push(chalk.red.bold(`${buildType} DTS failed:`));
|
|
93
|
-
if (isExecaError(e)) {
|
|
94
|
-
/**
|
|
95
|
-
* `shortMeessage` content like:
|
|
96
|
-
* 'Command failed with exit code 2: /Users/github/modern.js/playground/module/node_modules/.bin/tsc -p /Users/github/modern.js/playground/module/node_modules/tsconfig.temp.json --pretty'
|
|
97
|
-
* Don`t need it.
|
|
98
|
-
*/
|
|
99
|
-
if (e.stack) {
|
|
100
|
-
var _e$stack;
|
|
101
|
-
msgs.push((_e$stack = e.stack) === null || _e$stack === void 0 ? void 0 : _e$stack.replace(`${e.name}: ${e.shortMessage}`, ''));
|
|
102
|
-
}
|
|
103
|
-
} else {
|
|
104
|
-
msgs.push(e.stack);
|
|
105
|
-
}
|
|
106
|
-
return msgs;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
export class ModuleBuildError extends Error {
|
|
110
|
-
constructor(e) {
|
|
111
|
-
super(`\n\n${e}`);
|
|
112
|
-
Error.captureStackTrace(this, this.constructor);
|
|
113
|
-
this.name = 'ModuleBuildError';
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
export const isInternalError = e => {
|
|
117
|
-
if (e instanceof InternalBuildError || e instanceof InternalDTSError) {
|
|
118
|
-
return true;
|
|
119
|
-
}
|
|
120
|
-
return false;
|
|
121
|
-
};
|
|
122
|
-
export const isExecaError = e => {
|
|
123
|
-
if (e.stdout) {
|
|
124
|
-
return true;
|
|
125
|
-
}
|
|
126
|
-
return false;
|
|
127
|
-
};
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import { Import, fs, chalk } from '@modern-js/utils';
|
|
3
|
-
import pMap from 'p-map';
|
|
4
|
-
import { ReadlineUtils } from "../../utils/readline";
|
|
5
|
-
import { normalizeModuleConfig } from "./normalize";
|
|
6
|
-
import { buildingText, buildSuccessText } from "./constants";
|
|
7
|
-
import { ModuleBuildError, isInternalError } from "./error";
|
|
8
|
-
import { getAllDeps } from "./utils";
|
|
9
|
-
const bundle = Import.lazy('./bundle', require);
|
|
10
|
-
const bundleless = Import.lazy('./bundleless', require);
|
|
11
|
-
const bp = Import.lazy('./build-platform', require);
|
|
12
|
-
const copyUtils = Import.lazy('../../utils/copy', require);
|
|
13
|
-
export const checkPlatformAndRunBuild = async (platform, options) => {
|
|
14
|
-
const {
|
|
15
|
-
api,
|
|
16
|
-
isTsProject
|
|
17
|
-
} = options;
|
|
18
|
-
if (typeof platform === 'boolean' && platform) {
|
|
19
|
-
if (process.env.RUN_PLATFORM) {
|
|
20
|
-
await bp.buildPlatform(api, {
|
|
21
|
-
platform: 'all',
|
|
22
|
-
isTsProject
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
return {
|
|
26
|
-
exit: true
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
if (typeof platform === 'string') {
|
|
30
|
-
if (process.env.RUN_PLATFORM) {
|
|
31
|
-
await bp.buildPlatform(api, {
|
|
32
|
-
platform,
|
|
33
|
-
isTsProject
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
return {
|
|
37
|
-
exit: true
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
return {
|
|
41
|
-
exit: false
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
export const runBuild = async (api, normalizedModuleConfig, config) => {
|
|
45
|
-
await pMap(normalizedModuleConfig, async moduleConfig => {
|
|
46
|
-
if (moduleConfig.buildType === 'bundle') {
|
|
47
|
-
await bundle.build(api, moduleConfig);
|
|
48
|
-
} else {
|
|
49
|
-
await bundleless.build(api, moduleConfig, config);
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
};
|
|
53
|
-
export const buildInNormalMode = async (api, normalizedModuleConfig, config) => {
|
|
54
|
-
console.info(chalk.blue.bold(buildingText));
|
|
55
|
-
try {
|
|
56
|
-
// eslint-disable-next-line no-console
|
|
57
|
-
console.time(buildSuccessText);
|
|
58
|
-
await runBuild(api, normalizedModuleConfig, config);
|
|
59
|
-
ReadlineUtils.clearPrevLine(process.stdout);
|
|
60
|
-
// eslint-disable-next-line no-console
|
|
61
|
-
console.timeEnd(buildSuccessText);
|
|
62
|
-
} catch (e) {
|
|
63
|
-
ReadlineUtils.clearPrevLine(process.stdout);
|
|
64
|
-
if (isInternalError(e)) {
|
|
65
|
-
throw new ModuleBuildError(e);
|
|
66
|
-
} else {
|
|
67
|
-
throw e;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
export const build = async (api, config) => {
|
|
72
|
-
const {
|
|
73
|
-
platform,
|
|
74
|
-
clear = true,
|
|
75
|
-
isTsProject
|
|
76
|
-
} = config;
|
|
77
|
-
const appContext = api.useAppContext();
|
|
78
|
-
const {
|
|
79
|
-
appDirectory
|
|
80
|
-
} = appContext;
|
|
81
|
-
const modernConfig = api.useResolvedConfigContext();
|
|
82
|
-
const {
|
|
83
|
-
output: {
|
|
84
|
-
path: outputPath = 'dist'
|
|
85
|
-
}
|
|
86
|
-
} = modernConfig;
|
|
87
|
-
|
|
88
|
-
// build platform
|
|
89
|
-
const platformBuildRet = await checkPlatformAndRunBuild(platform, {
|
|
90
|
-
api,
|
|
91
|
-
isTsProject
|
|
92
|
-
});
|
|
93
|
-
if (platformBuildRet.exit) {
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
if (clear) {
|
|
97
|
-
fs.removeSync(path.join(appDirectory, outputPath));
|
|
98
|
-
}
|
|
99
|
-
const deps = getAllDeps(appDirectory);
|
|
100
|
-
|
|
101
|
-
// should normalize module tool config here, ensure the same config for build
|
|
102
|
-
const normalizedModuleConfig = normalizeModuleConfig({
|
|
103
|
-
buildFeatOption: config,
|
|
104
|
-
api,
|
|
105
|
-
deps
|
|
106
|
-
});
|
|
107
|
-
await copyUtils.copyTask({
|
|
108
|
-
modernConfig,
|
|
109
|
-
appContext
|
|
110
|
-
});
|
|
111
|
-
if (config.enableWatchMode) {
|
|
112
|
-
console.info(chalk.blue.underline('start build in watch mode...\n'));
|
|
113
|
-
await runBuild(api, normalizedModuleConfig, config);
|
|
114
|
-
} else {
|
|
115
|
-
await buildInNormalMode(api, normalizedModuleConfig, config);
|
|
116
|
-
}
|
|
117
|
-
};
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
// Universal JS 的默认选择,三份构建产物,支持 Node.js,对现代浏览器有优化
|
|
2
|
-
const universalJs = [{
|
|
3
|
-
format: 'esm',
|
|
4
|
-
target: 'es5',
|
|
5
|
-
outputPath: './js/treeshaking',
|
|
6
|
-
bundlelessOptions: {
|
|
7
|
-
style: {
|
|
8
|
-
compileMode: 'only-source-code'
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
}, {
|
|
12
|
-
format: 'cjs',
|
|
13
|
-
target: 'es6',
|
|
14
|
-
outputPath: './js/node'
|
|
15
|
-
}, {
|
|
16
|
-
format: 'esm',
|
|
17
|
-
target: 'es6',
|
|
18
|
-
outputPath: './js/modern'
|
|
19
|
-
}];
|
|
20
|
-
|
|
21
|
-
// Universal JS 的优化选择,两份构建产物,对现代浏览器无优化
|
|
22
|
-
const universalJsLite = [{
|
|
23
|
-
format: 'esm',
|
|
24
|
-
target: 'es5',
|
|
25
|
-
outputPath: './js/treeshaking',
|
|
26
|
-
bundlelessOptions: {
|
|
27
|
-
style: {
|
|
28
|
-
compileMode: 'only-source-code'
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}, {
|
|
32
|
-
format: 'cjs',
|
|
33
|
-
target: 'es6',
|
|
34
|
-
outputPath: './js/node'
|
|
35
|
-
}, {
|
|
36
|
-
format: 'esm',
|
|
37
|
-
target: 'es5',
|
|
38
|
-
outputPath: './js/modern'
|
|
39
|
-
}];
|
|
40
|
-
|
|
41
|
-
// 纯前端代码的默认选择,两份构建产物
|
|
42
|
-
const browserJs = [{
|
|
43
|
-
format: 'esm',
|
|
44
|
-
target: 'es5',
|
|
45
|
-
outputPath: './js/treeshaking',
|
|
46
|
-
bundlelessOptions: {
|
|
47
|
-
style: {
|
|
48
|
-
compileMode: 'only-source-code'
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}, {
|
|
52
|
-
format: 'esm',
|
|
53
|
-
target: 'es6',
|
|
54
|
-
outputPath: './js/node'
|
|
55
|
-
}, {
|
|
56
|
-
format: 'esm',
|
|
57
|
-
target: 'es6',
|
|
58
|
-
outputPath: './js/modern'
|
|
59
|
-
}];
|
|
60
|
-
|
|
61
|
-
// 纯前端代码的优化选择,单份构建产物,对现代浏览器无优化
|
|
62
|
-
const browserJsLite = [{
|
|
63
|
-
format: 'esm',
|
|
64
|
-
target: 'es5',
|
|
65
|
-
outputPath: './js/treeshaking',
|
|
66
|
-
bundlelessOptions: {
|
|
67
|
-
style: {
|
|
68
|
-
compileMode: 'only-source-code'
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}, {
|
|
72
|
-
format: 'esm',
|
|
73
|
-
target: 'es5',
|
|
74
|
-
outputPath: './js/node'
|
|
75
|
-
}, {
|
|
76
|
-
format: 'esm',
|
|
77
|
-
target: 'es5',
|
|
78
|
-
outputPath: './js/modern'
|
|
79
|
-
}];
|
|
80
|
-
|
|
81
|
-
// 纯 Node.js 代码的默认选择,两份构建产物
|
|
82
|
-
const nodeJs = [{
|
|
83
|
-
format: 'cjs',
|
|
84
|
-
target: 'es6',
|
|
85
|
-
outputPath: './js/node',
|
|
86
|
-
bundlelessOptions: {
|
|
87
|
-
style: {
|
|
88
|
-
compileMode: 'only-source-code'
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}, {
|
|
92
|
-
format: 'esm',
|
|
93
|
-
target: 'es6',
|
|
94
|
-
outputPath: './js/modern'
|
|
95
|
-
}];
|
|
96
|
-
export const DEFAULT_PACKAGE_MODE = 'universal-js';
|
|
97
|
-
export const PACKAGE_MODES = {
|
|
98
|
-
'universal-js': universalJs,
|
|
99
|
-
'universal-js-lite': universalJsLite,
|
|
100
|
-
'browser-js': browserJs,
|
|
101
|
-
'browser-js-lite': browserJsLite,
|
|
102
|
-
'node-js': nodeJs
|
|
103
|
-
};
|