@modern-js/module-tools 2.35.1 → 2.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build.js +43 -16
- package/dist/builder/build.d.ts +0 -10
- package/dist/builder/build.js +96 -208
- package/dist/builder/clear.d.ts +1 -4
- package/dist/builder/clear.js +32 -28
- package/dist/builder/copy.js +75 -60
- package/dist/builder/dts/index.js +27 -19
- package/dist/builder/dts/rollup.d.ts +6 -14
- package/dist/builder/dts/rollup.js +60 -37
- package/dist/builder/dts/tsc.d.ts +3 -2
- package/dist/builder/dts/tsc.js +50 -37
- package/dist/builder/esbuild/adapter.d.ts +3 -0
- package/dist/builder/esbuild/adapter.js +286 -0
- package/dist/builder/esbuild/hook.d.ts +4 -0
- package/dist/builder/esbuild/hook.js +103 -0
- package/dist/builder/esbuild/index.d.ts +35 -0
- package/dist/builder/esbuild/index.js +268 -0
- package/dist/builder/esbuild/resolve.d.ts +18 -0
- package/dist/builder/esbuild/resolve.js +140 -0
- package/dist/builder/esbuild/sourcemap.d.ts +16 -0
- package/dist/builder/esbuild/sourcemap.js +86 -0
- package/dist/builder/esbuild/transform.d.ts +7 -0
- package/dist/builder/esbuild/transform.js +45 -0
- package/dist/builder/esbuild/watch.d.ts +2 -0
- package/dist/builder/esbuild/watch.js +115 -0
- package/dist/builder/esbuild/write-file.d.ts +2 -0
- package/dist/builder/esbuild/write-file.js +89 -0
- package/dist/builder/feature/asset.d.ts +19 -0
- package/dist/builder/feature/asset.js +149 -0
- package/dist/builder/feature/format-cjs.d.ts +5 -0
- package/dist/builder/feature/format-cjs.js +53 -0
- package/dist/builder/feature/index.d.ts +2 -0
- package/dist/builder/feature/index.js +74 -0
- package/dist/builder/feature/json.d.ts +5 -0
- package/dist/builder/feature/json.js +47 -0
- package/dist/builder/feature/redirect.d.ts +5 -0
- package/dist/builder/feature/redirect.js +223 -0
- package/dist/builder/feature/style/index.d.ts +5 -0
- package/dist/builder/feature/style/index.js +94 -0
- package/dist/builder/feature/style/lessAliasPlugin.d.ts +12 -0
- package/dist/builder/feature/style/lessAliasPlugin.js +70 -0
- package/dist/builder/feature/style/lessRender.d.ts +2 -0
- package/dist/builder/feature/style/lessRender.js +64 -0
- package/dist/builder/feature/style/postcssTransformer.d.ts +6 -0
- package/dist/builder/feature/style/postcssTransformer.js +95 -0
- package/dist/builder/feature/style/postcssUrlPlugin.d.ts +6 -0
- package/dist/builder/feature/style/postcssUrlPlugin.js +58 -0
- package/dist/builder/feature/style/sassRender.d.ts +2 -0
- package/dist/builder/feature/style/sassRender.js +85 -0
- package/dist/builder/feature/style/transformStyle.d.ts +13 -0
- package/dist/builder/feature/style/transformStyle.js +101 -0
- package/dist/builder/feature/style/utils.d.ts +18 -0
- package/dist/builder/feature/style/utils.js +130 -0
- package/dist/builder/feature/swc.d.ts +9 -0
- package/dist/builder/feature/swc.js +170 -0
- package/dist/builder/feature/terser.d.ts +5 -0
- package/dist/builder/feature/terser.js +83 -0
- package/dist/builder/index.js +59 -28
- package/dist/builder/platform.js +38 -23
- package/dist/cli.js +58 -29
- package/dist/command.js +62 -38
- package/dist/config/defineConfig.js +25 -17
- package/dist/config/legacySchema.js +35 -32
- package/dist/config/merge.js +69 -36
- package/dist/config/normalize.js +63 -46
- package/dist/config/schema.d.ts +48 -0
- package/dist/config/schema.js +53 -34
- package/dist/config/transformLegacyConfig.js +67 -61
- package/dist/config/valid.d.ts +2 -2
- package/dist/config/valid.js +44 -21
- package/dist/constants/build.d.ts +5 -1
- package/dist/constants/build.js +88 -46
- package/dist/constants/color.js +27 -20
- package/dist/constants/dts.js +27 -20
- package/dist/constants/file.d.ts +2 -2
- package/dist/constants/file.js +48 -25
- package/dist/constants/legacy-preset.js +45 -32
- package/dist/constants/loader.d.ts +2 -0
- package/dist/constants/loader.js +53 -0
- package/dist/constants/log.d.ts +0 -8
- package/dist/constants/log.js +27 -41
- package/dist/constants/preset.d.ts +4 -4
- package/dist/constants/preset.js +55 -62
- package/dist/debug.d.ts +4 -0
- package/dist/debug.js +37 -0
- package/dist/dev.js +42 -25
- package/dist/error.js +49 -42
- package/dist/hooks/build.d.ts +1 -2
- package/dist/hooks/build.js +36 -28
- package/dist/hooks/dev.js +32 -17
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.js +31 -16
- package/dist/hooks/misc.d.ts +5 -2
- package/dist/hooks/misc.js +31 -12
- package/dist/index.d.ts +2 -1
- package/dist/index.js +39 -32
- package/dist/locale/en.js +32 -17
- package/dist/locale/index.d.ts +2 -1
- package/dist/locale/index.js +31 -24
- package/dist/locale/zh.js +32 -17
- package/dist/plugins.js +28 -13
- package/dist/types/color.js +15 -5
- package/dist/types/command.d.ts +3 -3
- package/dist/types/command.js +15 -5
- package/dist/types/config/copy.js +15 -5
- package/dist/types/config/dev.js +15 -5
- package/dist/types/config/index.d.ts +87 -52
- package/dist/types/config/index.js +24 -6
- package/dist/types/config/style.d.ts +58 -6
- package/dist/types/config/style.js +15 -5
- package/dist/types/context.js +15 -5
- package/dist/types/dts.d.ts +14 -3
- package/dist/types/dts.js +15 -5
- package/dist/types/esbuild.d.ts +107 -0
- package/dist/types/esbuild.js +32 -0
- package/dist/types/hooks.js +15 -5
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +32 -11
- package/dist/types/legacyConfig/index.js +15 -5
- package/dist/types/legacyConfig/output.d.ts +4 -4
- package/dist/types/legacyConfig/output.js +15 -5
- package/dist/types/legacyConfig/source.js +15 -5
- package/dist/types/legacyConfig/tools.js +15 -5
- package/dist/utils/assert.d.ts +5 -0
- package/dist/utils/assert.js +50 -0
- package/dist/utils/builder.d.ts +10 -14
- package/dist/utils/builder.js +59 -59
- package/dist/utils/common.d.ts +1 -1
- package/dist/utils/common.js +25 -17
- package/dist/utils/dts.d.ts +26 -9
- package/dist/utils/dts.js +98 -64
- package/dist/utils/hash.d.ts +2 -0
- package/dist/utils/hash.js +31 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/index.js +42 -0
- package/dist/utils/input.js +47 -24
- package/dist/utils/log.d.ts +1 -2
- package/dist/utils/log.js +36 -20
- package/dist/utils/map.d.ts +13 -0
- package/dist/utils/map.js +58 -0
- package/dist/utils/onExit.js +35 -11
- package/dist/utils/print.d.ts +2 -2
- package/dist/utils/print.js +52 -49
- package/dist/utils/style.d.ts +5 -23
- package/dist/utils/style.js +57 -37
- package/dist/utils/tspath.js +114 -0
- package/package.json +61 -50
- package/vitest.config.ts +20 -0
- package/dist/build.js.map +0 -1
- package/dist/builder/build.js.map +0 -1
- package/dist/builder/clear.js.map +0 -1
- package/dist/builder/copy.js.map +0 -1
- package/dist/builder/dts/index.js.map +0 -1
- package/dist/builder/dts/rollup.js.map +0 -1
- package/dist/builder/dts/tsc.js.map +0 -1
- package/dist/builder/index.js.map +0 -1
- package/dist/builder/platform.js.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/command.js.map +0 -1
- package/dist/config/defineConfig.js.map +0 -1
- package/dist/config/legacySchema.js.map +0 -1
- package/dist/config/merge.js.map +0 -1
- package/dist/config/normalize.js.map +0 -1
- package/dist/config/schema.js.map +0 -1
- package/dist/config/transformLegacyConfig.js.map +0 -1
- package/dist/config/valid.js.map +0 -1
- package/dist/constants/build.js.map +0 -1
- package/dist/constants/color.js.map +0 -1
- package/dist/constants/dts.js.map +0 -1
- package/dist/constants/file.js.map +0 -1
- package/dist/constants/legacy-preset.js.map +0 -1
- package/dist/constants/log.js.map +0 -1
- package/dist/constants/preset.js.map +0 -1
- package/dist/dev.js.map +0 -1
- package/dist/error.js.map +0 -1
- package/dist/hooks/build.js.map +0 -1
- package/dist/hooks/dev.js.map +0 -1
- package/dist/hooks/index.js.map +0 -1
- package/dist/hooks/misc.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/locale/en.js.map +0 -1
- package/dist/locale/index.js.map +0 -1
- package/dist/locale/zh.js.map +0 -1
- package/dist/plugins.js.map +0 -1
- package/dist/types/color.js.map +0 -1
- package/dist/types/command.js.map +0 -1
- package/dist/types/config/copy.js.map +0 -1
- package/dist/types/config/dev.js.map +0 -1
- package/dist/types/config/index.js.map +0 -1
- package/dist/types/config/style.js.map +0 -1
- package/dist/types/context.js.map +0 -1
- package/dist/types/dts.js.map +0 -1
- package/dist/types/hooks.js.map +0 -1
- package/dist/types/index.js.map +0 -1
- package/dist/types/legacyConfig/index.js.map +0 -1
- package/dist/types/legacyConfig/output.js.map +0 -1
- package/dist/types/legacyConfig/source.js.map +0 -1
- package/dist/types/legacyConfig/tools.js.map +0 -1
- package/dist/types/utils.d.ts +0 -5
- package/dist/types/utils.js +0 -4
- package/dist/utils/builder.js.map +0 -1
- package/dist/utils/common.js.map +0 -1
- package/dist/utils/context.d.ts +0 -7
- package/dist/utils/context.js +0 -23
- package/dist/utils/context.js.map +0 -1
- package/dist/utils/dts.js.map +0 -1
- package/dist/utils/input.js.map +0 -1
- package/dist/utils/language.d.ts +0 -1
- package/dist/utils/language.js +0 -22
- package/dist/utils/language.js.map +0 -1
- package/dist/utils/libuild-plugin.d.ts +0 -3
- package/dist/utils/libuild-plugin.js +0 -31
- package/dist/utils/libuild-plugin.js.map +0 -1
- package/dist/utils/log.js.map +0 -1
- package/dist/utils/onExit.js.map +0 -1
- package/dist/utils/path.d.ts +0 -1
- package/dist/utils/path.js +0 -19
- package/dist/utils/path.js.map +0 -1
- package/dist/utils/print.js.map +0 -1
- package/dist/utils/style.js.map +0 -1
- package/dist/utils/tspathsTransform.js +0 -91
- package/dist/utils/tspathsTransform.js.map +0 -1
- /package/dist/utils/{tspathsTransform.d.ts → tspath.d.ts} +0 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { BuildContext, BuildOptions, OnLoadArgs, OnLoadResult, BuildResult, ImportKind } from 'esbuild';
|
|
3
|
+
import type { AsyncSeriesBailHook, AsyncSeriesWaterfallHook } from 'tapable';
|
|
4
|
+
import { FSWatcher } from '@modern-js/utils';
|
|
5
|
+
import { BaseBuildConfig } from './config';
|
|
6
|
+
import { ModuleTools, PluginAPI } from '.';
|
|
7
|
+
export interface SourceMap {
|
|
8
|
+
mappings: string;
|
|
9
|
+
names: string[];
|
|
10
|
+
sources: (string | null)[];
|
|
11
|
+
version: number;
|
|
12
|
+
sourcesContent?: (string | null)[];
|
|
13
|
+
}
|
|
14
|
+
export type LoadResult = Pick<OnLoadResult, 'contents' | 'loader' | 'resolveDir'> & {
|
|
15
|
+
map?: SourceMap;
|
|
16
|
+
};
|
|
17
|
+
export interface BuilderHooks {
|
|
18
|
+
/**
|
|
19
|
+
* Equal to esbuild#onLoad
|
|
20
|
+
*/
|
|
21
|
+
load: AsyncSeriesBailHook<[OnLoadArgs], LoadResult | undefined | void>;
|
|
22
|
+
/**
|
|
23
|
+
* Transform code after it is loaded.
|
|
24
|
+
*/
|
|
25
|
+
transform: AsyncSeriesWaterfallHook<Source>;
|
|
26
|
+
/**
|
|
27
|
+
* Modify the chunk
|
|
28
|
+
*/
|
|
29
|
+
renderChunk: AsyncSeriesWaterfallHook<[Chunk]>;
|
|
30
|
+
}
|
|
31
|
+
export type Context = {
|
|
32
|
+
config: BaseBuildConfig;
|
|
33
|
+
watch: boolean;
|
|
34
|
+
root: string;
|
|
35
|
+
api: PluginAPI<ModuleTools>;
|
|
36
|
+
};
|
|
37
|
+
export interface ICompiler {
|
|
38
|
+
reBuild: (type: 'link' | 'change', config: BaseBuildConfig) => Promise<void>;
|
|
39
|
+
css_resolve: (id: string, dir: string) => string;
|
|
40
|
+
node_resolve: (id: string, dir: string, kind: ImportKind) => string | false;
|
|
41
|
+
init: () => Promise<void>;
|
|
42
|
+
watcher?: FSWatcher;
|
|
43
|
+
instance?: BuildContext;
|
|
44
|
+
result?: BuildResult;
|
|
45
|
+
reBuildCount: number;
|
|
46
|
+
buildOptions: BuildOptions;
|
|
47
|
+
context: Context;
|
|
48
|
+
config: BaseBuildConfig;
|
|
49
|
+
hooks: BuilderHooks;
|
|
50
|
+
api: PluginAPI<ModuleTools>;
|
|
51
|
+
outputChunk: Map<string, Chunk>;
|
|
52
|
+
virtualModule: Map<string, string>;
|
|
53
|
+
build: (() => Promise<void>) & (() => Promise<void>);
|
|
54
|
+
emitAsset: ((name: string, chunk: AssetChunk) => void) & ((name: string, chunk: JsChunk) => void) & ((name: string, chunk: string) => void);
|
|
55
|
+
watchedFiles: Set<string>;
|
|
56
|
+
addWatchFile: (id: string) => void;
|
|
57
|
+
getTransformContext: (path: string) => ITransformContext;
|
|
58
|
+
getSourcemapContext: (path: string) => ISourcemapContext;
|
|
59
|
+
close: () => Promise<void>;
|
|
60
|
+
}
|
|
61
|
+
export interface ISourcemapContext {
|
|
62
|
+
addSourceMap: (pluginId: number, map?: SourceMap) => void;
|
|
63
|
+
getInlineSourceMap: () => string;
|
|
64
|
+
getSourceMap: () => SourceMap | undefined;
|
|
65
|
+
getSourceMapChain: () => SourceMap[];
|
|
66
|
+
genPluginId: (id: string) => number;
|
|
67
|
+
}
|
|
68
|
+
export interface ITransformContext extends ISourcemapContext {
|
|
69
|
+
addTransformResult: (pluginId: number, result: CacheValue) => void;
|
|
70
|
+
getValidCache: (pluginId: number, code: string) => undefined | CacheValue;
|
|
71
|
+
}
|
|
72
|
+
export type Source = {
|
|
73
|
+
code: string;
|
|
74
|
+
map?: SourceMap;
|
|
75
|
+
path: string;
|
|
76
|
+
loader?: string;
|
|
77
|
+
};
|
|
78
|
+
export interface CacheValue extends Source {
|
|
79
|
+
originCode: string;
|
|
80
|
+
}
|
|
81
|
+
export type AssetChunk = {
|
|
82
|
+
type: 'asset';
|
|
83
|
+
contents: string | Buffer;
|
|
84
|
+
entryPoint?: string;
|
|
85
|
+
/**
|
|
86
|
+
* absolute file path
|
|
87
|
+
*/
|
|
88
|
+
fileName: string;
|
|
89
|
+
originalFileName?: string;
|
|
90
|
+
};
|
|
91
|
+
export type JsChunk = {
|
|
92
|
+
type: 'chunk';
|
|
93
|
+
contents: string;
|
|
94
|
+
entryPoint?: string;
|
|
95
|
+
/**
|
|
96
|
+
* absolute file path
|
|
97
|
+
*/
|
|
98
|
+
fileName: string;
|
|
99
|
+
map?: SourceMap;
|
|
100
|
+
modules?: Record<string, any>;
|
|
101
|
+
originalFileName?: string;
|
|
102
|
+
};
|
|
103
|
+
export type Chunk = AssetChunk | JsChunk;
|
|
104
|
+
export declare const enum ChunkType {
|
|
105
|
+
chunk = "chunk",
|
|
106
|
+
asset = "asset",
|
|
107
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var esbuild_exports = {};
|
|
20
|
+
__export(esbuild_exports, {
|
|
21
|
+
ChunkType: () => ChunkType
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(esbuild_exports);
|
|
24
|
+
var ChunkType;
|
|
25
|
+
(function(ChunkType2) {
|
|
26
|
+
ChunkType2["chunk"] = "chunk";
|
|
27
|
+
ChunkType2["asset"] = "asset";
|
|
28
|
+
})(ChunkType || (ChunkType = {}));
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
ChunkType
|
|
32
|
+
});
|
package/dist/types/hooks.js
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var hooks_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(hooks_exports);
|
package/dist/types/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export * from './config';
|
|
|
8
8
|
export * from './legacyConfig';
|
|
9
9
|
export * from './dts';
|
|
10
10
|
export * from './context';
|
|
11
|
+
export * from './esbuild';
|
|
11
12
|
export type { CliPlugin, IAppContext, PluginAPI } from '@modern-js/core';
|
|
12
13
|
export type ModuleTools = {
|
|
13
14
|
hooks: ModuleToolsHooks;
|
package/dist/types/index.js
CHANGED
|
@@ -1,13 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var types_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(types_exports);
|
|
18
|
+
__reExport(types_exports, require("./hooks"), module.exports);
|
|
19
|
+
__reExport(types_exports, require("./command"), module.exports);
|
|
20
|
+
__reExport(types_exports, require("./config"), module.exports);
|
|
21
|
+
__reExport(types_exports, require("./legacyConfig"), module.exports);
|
|
22
|
+
__reExport(types_exports, require("./dts"), module.exports);
|
|
23
|
+
__reExport(types_exports, require("./context"), module.exports);
|
|
24
|
+
__reExport(types_exports, require("./esbuild"), module.exports);
|
|
25
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
26
|
+
0 && (module.exports = {
|
|
27
|
+
...require("./hooks"),
|
|
28
|
+
...require("./command"),
|
|
29
|
+
...require("./config"),
|
|
30
|
+
...require("./legacyConfig"),
|
|
31
|
+
...require("./dts"),
|
|
32
|
+
...require("./context"),
|
|
33
|
+
...require("./esbuild")
|
|
4
34
|
});
|
|
5
|
-
const _export_star = require("@swc/helpers/_/_export_star");
|
|
6
|
-
_export_star._(require("./hooks"), exports);
|
|
7
|
-
_export_star._(require("./command"), exports);
|
|
8
|
-
_export_star._(require("./config"), exports);
|
|
9
|
-
_export_star._(require("./legacyConfig"), exports);
|
|
10
|
-
_export_star._(require("./dts"), exports);
|
|
11
|
-
_export_star._(require("./context"), exports);
|
|
12
|
-
|
|
13
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var legacyConfig_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(legacyConfig_exports);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Externals, Minify, Platform } from '../config';
|
|
2
2
|
export type LegacyBuildPreset = 'npm-library' | 'npm-library-with-umd' | 'npm-component' | 'npm-component-with-umd';
|
|
3
3
|
export type LegacyFormat = 'esm' | 'cjs' | 'umd';
|
|
4
4
|
export type LegacyTarget = 'es5' | 'es6' | 'es2015' | 'es2016' | 'es2017' | 'es2018' | 'es2019' | 'es2020' | 'esnext';
|
|
@@ -6,10 +6,10 @@ export type LegacyBuildType = 'bundle' | 'bundleless';
|
|
|
6
6
|
export type LegacySourceMap = boolean | 'inline' | 'external';
|
|
7
7
|
export type LegacyBundleOptions = {
|
|
8
8
|
entry?: Record<string, string>;
|
|
9
|
-
platform?:
|
|
9
|
+
platform?: Platform;
|
|
10
10
|
splitting?: boolean;
|
|
11
|
-
minify?:
|
|
12
|
-
externals?:
|
|
11
|
+
minify?: Minify;
|
|
12
|
+
externals?: Externals;
|
|
13
13
|
skipDeps?: boolean;
|
|
14
14
|
getModuleId?: (moduleName: string) => string | undefined;
|
|
15
15
|
};
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var output_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(output_exports);
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var source_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(source_exports);
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var tools_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(tools_exports);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function isStyleExt(path: string): boolean;
|
|
2
|
+
export declare function isJsExt(path: string): boolean;
|
|
3
|
+
export declare function isJsLoader(loader?: string): boolean;
|
|
4
|
+
export declare function isTsExt(path: string): boolean;
|
|
5
|
+
export declare function isTsLoader(loader?: string): boolean;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var assert_exports = {};
|
|
20
|
+
__export(assert_exports, {
|
|
21
|
+
isJsExt: () => isJsExt,
|
|
22
|
+
isJsLoader: () => isJsLoader,
|
|
23
|
+
isStyleExt: () => isStyleExt,
|
|
24
|
+
isTsExt: () => isTsExt,
|
|
25
|
+
isTsLoader: () => isTsLoader
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(assert_exports);
|
|
28
|
+
function isStyleExt(path) {
|
|
29
|
+
return /\.(c|le|sa|sc)ss(\?.*)?$/.test(path);
|
|
30
|
+
}
|
|
31
|
+
function isJsExt(path) {
|
|
32
|
+
return /\.(m|c)?(j|t)sx?(\?.*)?$/.test(path);
|
|
33
|
+
}
|
|
34
|
+
function isJsLoader(loader) {
|
|
35
|
+
return loader === "js" || loader === "ts" || loader === "tsx" || loader === "jsx";
|
|
36
|
+
}
|
|
37
|
+
function isTsExt(path) {
|
|
38
|
+
return /\.(m|c)?tsx?(\?.*)?$/.test(path);
|
|
39
|
+
}
|
|
40
|
+
function isTsLoader(loader) {
|
|
41
|
+
return loader === "ts" || loader === "tsx";
|
|
42
|
+
}
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
isJsExt,
|
|
46
|
+
isJsLoader,
|
|
47
|
+
isStyleExt,
|
|
48
|
+
isTsExt,
|
|
49
|
+
isTsLoader
|
|
50
|
+
});
|
package/dist/utils/builder.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import type { ExternalHelpers
|
|
1
|
+
import type { ExternalHelpers } from '../types/config';
|
|
2
|
+
type Query = Record<string, string | boolean>;
|
|
3
|
+
type ResolveResult = {
|
|
4
|
+
originalFilePath: string;
|
|
5
|
+
query: Query;
|
|
6
|
+
rawQuery?: string;
|
|
7
|
+
};
|
|
2
8
|
export declare const getAllDeps: <T>(appDirectory: string, options?: {
|
|
3
9
|
dependencies?: boolean;
|
|
4
10
|
devDependencies?: boolean;
|
|
@@ -8,16 +14,6 @@ export declare const checkSwcHelpers: (options: {
|
|
|
8
14
|
appDirectory: string;
|
|
9
15
|
externalHelpers: ExternalHelpers;
|
|
10
16
|
}) => Promise<void>;
|
|
11
|
-
export declare const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
format: Format;
|
|
15
|
-
disableSwcTransform?: boolean;
|
|
16
|
-
}) => boolean;
|
|
17
|
-
export declare const matchEs5PluginCondition: (condtionOptions: {
|
|
18
|
-
sourceType: 'commonjs' | 'module';
|
|
19
|
-
buildType: BuildType;
|
|
20
|
-
format: Format;
|
|
21
|
-
target: Target;
|
|
22
|
-
disableSwcTransform?: boolean;
|
|
23
|
-
}) => boolean;
|
|
17
|
+
export declare const normalizeSlashes: (file: string) => string;
|
|
18
|
+
export declare const resolvePathAndQuery: (originalPath: string) => ResolveResult;
|
|
19
|
+
export {};
|
package/dist/utils/builder.js
CHANGED
|
@@ -1,35 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
6
9
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return getAllDeps;
|
|
15
|
-
},
|
|
16
|
-
checkSwcHelpers: function() {
|
|
17
|
-
return checkSwcHelpers;
|
|
18
|
-
},
|
|
19
|
-
matchSwcTransformCondition: function() {
|
|
20
|
-
return matchSwcTransformCondition;
|
|
21
|
-
},
|
|
22
|
-
matchEs5PluginCondition: function() {
|
|
23
|
-
return matchEs5PluginCondition;
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
24
17
|
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var builder_exports = {};
|
|
30
|
+
__export(builder_exports, {
|
|
31
|
+
checkSwcHelpers: () => checkSwcHelpers,
|
|
32
|
+
getAllDeps: () => getAllDeps,
|
|
33
|
+
normalizeSlashes: () => normalizeSlashes,
|
|
34
|
+
resolvePathAndQuery: () => resolvePathAndQuery
|
|
25
35
|
});
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
36
|
+
module.exports = __toCommonJS(builder_exports);
|
|
37
|
+
var import_path = __toESM(require("path"));
|
|
38
|
+
var import_querystring = __toESM(require("querystring"));
|
|
39
|
+
var import_utils = require("@modern-js/utils");
|
|
30
40
|
const getAllDeps = async (appDirectory, options = {}) => {
|
|
31
41
|
try {
|
|
32
|
-
const json = JSON.parse(
|
|
42
|
+
const json = JSON.parse(import_utils.fs.readFileSync(import_path.default.resolve(appDirectory, "./package.json"), "utf8"));
|
|
33
43
|
let deps = [];
|
|
34
44
|
if (options.dependencies) {
|
|
35
45
|
deps = [
|
|
@@ -51,7 +61,7 @@ const getAllDeps = async (appDirectory, options = {}) => {
|
|
|
51
61
|
}
|
|
52
62
|
return deps;
|
|
53
63
|
} catch (e) {
|
|
54
|
-
|
|
64
|
+
import_utils.logger.warn("package.json is broken");
|
|
55
65
|
return [];
|
|
56
66
|
}
|
|
57
67
|
};
|
|
@@ -66,41 +76,31 @@ const checkSwcHelpers = async (options) => {
|
|
|
66
76
|
});
|
|
67
77
|
const swcHelpersPkgName = "@swc/helpers";
|
|
68
78
|
if (!deps.includes(swcHelpersPkgName)) {
|
|
69
|
-
const local = await Promise.resolve().then(() =>
|
|
79
|
+
const local = await Promise.resolve().then(() => __toESM(require("../locale")));
|
|
70
80
|
throw new Error(local.i18n.t(local.localeKeys.errors.externalHelpers));
|
|
71
81
|
}
|
|
72
82
|
};
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
if (disableSwcTransform) {
|
|
76
|
-
return false;
|
|
77
|
-
}
|
|
78
|
-
if (sourceType === "commonjs") {
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
if (buildType === "bundleless") {
|
|
82
|
-
return true;
|
|
83
|
-
}
|
|
84
|
-
if (format === "esm" || format === "iife") {
|
|
85
|
-
return true;
|
|
86
|
-
}
|
|
87
|
-
return false;
|
|
83
|
+
const normalizeSlashes = (file) => {
|
|
84
|
+
return file.split(import_path.default.win32.sep).join("/");
|
|
88
85
|
};
|
|
89
|
-
const
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
if (sourceType === "commonjs") {
|
|
98
|
-
return true;
|
|
99
|
-
}
|
|
100
|
-
if (buildType === "bundle" && format === "cjs") {
|
|
101
|
-
return true;
|
|
86
|
+
const resolvePathAndQuery = (originalPath) => {
|
|
87
|
+
const [filePath, queryStr] = originalPath.split("?");
|
|
88
|
+
const query = import_querystring.default.parse(queryStr !== null && queryStr !== void 0 ? queryStr : "");
|
|
89
|
+
for (const key of Object.keys(query)) {
|
|
90
|
+
if (query[key] === "") {
|
|
91
|
+
query[key] = true;
|
|
92
|
+
}
|
|
102
93
|
}
|
|
103
|
-
return
|
|
94
|
+
return {
|
|
95
|
+
query,
|
|
96
|
+
originalFilePath: filePath,
|
|
97
|
+
rawQuery: queryStr
|
|
98
|
+
};
|
|
104
99
|
};
|
|
105
|
-
|
|
106
|
-
|
|
100
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
101
|
+
0 && (module.exports = {
|
|
102
|
+
checkSwcHelpers,
|
|
103
|
+
getAllDeps,
|
|
104
|
+
normalizeSlashes,
|
|
105
|
+
resolvePathAndQuery
|
|
106
|
+
});
|
package/dist/utils/common.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* transform ['a', 'b'] to {a: undefined, b: undefined}
|
|
2
|
+
* transform ['a', 'b'] to { a: undefined, b: undefined }
|
|
3
3
|
*/
|
|
4
4
|
export declare const transformUndefineObject: (arr: string[]) => Record<string, undefined>;
|
|
5
5
|
export declare function mapValue<T = any, U = any>(obj: Record<string, T>, mapper: (x: T) => U): Record<string, U>;
|
package/dist/utils/common.js
CHANGED
|
@@ -1,22 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
6
7
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return transformUndefineObject;
|
|
15
|
-
},
|
|
16
|
-
mapValue: function() {
|
|
17
|
-
return mapValue;
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
15
|
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var common_exports = {};
|
|
20
|
+
__export(common_exports, {
|
|
21
|
+
mapValue: () => mapValue,
|
|
22
|
+
transformUndefineObject: () => transformUndefineObject
|
|
19
23
|
});
|
|
24
|
+
module.exports = __toCommonJS(common_exports);
|
|
20
25
|
const transformUndefineObject = (arr) => {
|
|
21
26
|
return arr.reduce((o, key) => {
|
|
22
27
|
return {
|
|
@@ -31,5 +36,8 @@ function mapValue(obj, mapper) {
|
|
|
31
36
|
mapper(value)
|
|
32
37
|
]));
|
|
33
38
|
}
|
|
34
|
-
|
|
35
|
-
|
|
39
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
+
0 && (module.exports = {
|
|
41
|
+
mapValue,
|
|
42
|
+
transformUndefineObject
|
|
43
|
+
});
|