@modern-js/module-tools 2.35.1 → 2.36.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 +1 -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 +275 -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 +17 -0
- package/dist/builder/esbuild/resolve.js +125 -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 +217 -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 +124 -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.d.ts +1 -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.d.ts +1 -0
- package/dist/config/merge.js +69 -36
- package/dist/config/normalize.d.ts +1 -0
- 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.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 +64 -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,53 @@
|
|
|
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 name2 in all)
|
|
8
|
+
__defProp(target, name2, { get: all[name2], 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 format_cjs_exports = {};
|
|
20
|
+
__export(format_cjs_exports, {
|
|
21
|
+
formatCjs: () => formatCjs
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(format_cjs_exports);
|
|
24
|
+
var import_sucrase = require("sucrase");
|
|
25
|
+
const name = "format-cjs";
|
|
26
|
+
const apply = (compiler) => {
|
|
27
|
+
compiler.hooks.renderChunk.tapPromise({
|
|
28
|
+
name
|
|
29
|
+
}, async (chunk) => {
|
|
30
|
+
if (chunk.fileName.endsWith(".js") && chunk.type === "chunk") {
|
|
31
|
+
const code = chunk.contents.toString();
|
|
32
|
+
const result = (0, import_sucrase.transform)(code, {
|
|
33
|
+
transforms: [
|
|
34
|
+
"imports"
|
|
35
|
+
]
|
|
36
|
+
});
|
|
37
|
+
return {
|
|
38
|
+
...chunk,
|
|
39
|
+
contents: result.code,
|
|
40
|
+
map: result.sourceMap
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
return chunk;
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
const formatCjs = {
|
|
47
|
+
name,
|
|
48
|
+
apply
|
|
49
|
+
};
|
|
50
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
+
0 && (module.exports = {
|
|
52
|
+
formatCjs
|
|
53
|
+
});
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
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) => {
|
|
9
|
+
for (var name in all)
|
|
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 });
|
|
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 feature_exports = {};
|
|
30
|
+
__export(feature_exports, {
|
|
31
|
+
getInternalList: () => getInternalList
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(feature_exports);
|
|
34
|
+
var import_dts = require("../../utils/dts");
|
|
35
|
+
var import_format_cjs = require("./format-cjs");
|
|
36
|
+
var import_style = require("./style");
|
|
37
|
+
var import_terser = require("./terser");
|
|
38
|
+
var import_asset = require("./asset");
|
|
39
|
+
async function getInternalList(context) {
|
|
40
|
+
var _userTsconfig_compilerOptions;
|
|
41
|
+
const internal = [];
|
|
42
|
+
const { config } = context;
|
|
43
|
+
internal.push(import_asset.asset, import_style.css);
|
|
44
|
+
if (config.buildType === "bundle" && config.format === "cjs" && config.splitting) {
|
|
45
|
+
internal.push(import_format_cjs.formatCjs);
|
|
46
|
+
}
|
|
47
|
+
if (config.buildType === "bundleless") {
|
|
48
|
+
const { redirect } = await Promise.resolve().then(() => __toESM(require("./redirect")));
|
|
49
|
+
const { json } = await Promise.resolve().then(() => __toESM(require("./json")));
|
|
50
|
+
internal.push(redirect, json);
|
|
51
|
+
}
|
|
52
|
+
if (config.minify && config.minify !== "esbuild") {
|
|
53
|
+
internal.push(import_terser.minify);
|
|
54
|
+
}
|
|
55
|
+
const userTsconfig = await (0, import_dts.getProjectTsconfig)(context.config.tsconfig);
|
|
56
|
+
var _userTsconfig_compilerOptions_emitDecoratorMetadata;
|
|
57
|
+
const emitDecoratorMetadata = (_userTsconfig_compilerOptions_emitDecoratorMetadata = userTsconfig === null || userTsconfig === void 0 ? void 0 : (_userTsconfig_compilerOptions = userTsconfig.compilerOptions) === null || _userTsconfig_compilerOptions === void 0 ? void 0 : _userTsconfig_compilerOptions.emitDecoratorMetadata) !== null && _userTsconfig_compilerOptions_emitDecoratorMetadata !== void 0 ? _userTsconfig_compilerOptions_emitDecoratorMetadata : false;
|
|
58
|
+
const { transformImport, transformLodash, externalHelpers, format, target } = context.config;
|
|
59
|
+
const enbaleSwcTransform = transformImport.length > 0 || transformLodash || externalHelpers || emitDecoratorMetadata;
|
|
60
|
+
const enableSwcRenderChunk = enbaleSwcTransform ? format === "umd" : format === "umd" || target === "es5";
|
|
61
|
+
if (enbaleSwcTransform) {
|
|
62
|
+
const { swcTransform } = await Promise.resolve().then(() => __toESM(require("./swc")));
|
|
63
|
+
internal.push(swcTransform(userTsconfig));
|
|
64
|
+
}
|
|
65
|
+
if (enableSwcRenderChunk) {
|
|
66
|
+
const { swcRenderChunk } = await Promise.resolve().then(() => __toESM(require("./swc")));
|
|
67
|
+
internal.push(swcRenderChunk);
|
|
68
|
+
}
|
|
69
|
+
return internal;
|
|
70
|
+
}
|
|
71
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
72
|
+
0 && (module.exports = {
|
|
73
|
+
getInternalList
|
|
74
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
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 name2 in all)
|
|
8
|
+
__defProp(target, name2, { get: all[name2], 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 json_exports = {};
|
|
20
|
+
__export(json_exports, {
|
|
21
|
+
json: () => json
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(json_exports);
|
|
24
|
+
var import_fs = require("fs");
|
|
25
|
+
const isJsonExt = (path) => {
|
|
26
|
+
return path.endsWith(".json");
|
|
27
|
+
};
|
|
28
|
+
const name = "json";
|
|
29
|
+
const json = {
|
|
30
|
+
name,
|
|
31
|
+
apply(compiler) {
|
|
32
|
+
compiler.hooks.load.tapPromise({
|
|
33
|
+
name
|
|
34
|
+
}, async (args) => {
|
|
35
|
+
if (isJsonExt(args.path)) {
|
|
36
|
+
return {
|
|
37
|
+
contents: (0, import_fs.readFileSync)(args.path),
|
|
38
|
+
loader: "copy"
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
45
|
+
0 && (module.exports = {
|
|
46
|
+
json
|
|
47
|
+
});
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
"use strict";
|
|
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) => {
|
|
9
|
+
for (var name2 in all)
|
|
10
|
+
__defProp(target, name2, { get: all[name2], 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 });
|
|
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 redirect_exports = {};
|
|
30
|
+
__export(redirect_exports, {
|
|
31
|
+
redirect: () => redirect
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(redirect_exports);
|
|
34
|
+
var import_path = require("path");
|
|
35
|
+
var import_napi = require("@ast-grep/napi");
|
|
36
|
+
var import_magic_string = __toESM(require("magic-string"));
|
|
37
|
+
var import_tsconfig_paths = require("@modern-js/utils/tsconfig-paths");
|
|
38
|
+
var import_utils = require("@modern-js/utils");
|
|
39
|
+
var import_file = require("../../constants/file");
|
|
40
|
+
var import_utils2 = require("../../utils");
|
|
41
|
+
var import_asset = require("./asset");
|
|
42
|
+
var import_postcssTransformer = require("./style/postcssTransformer");
|
|
43
|
+
async function redirectImport(compiler, code, modules, aliasRecord, filePath, outputDir, matchPath) {
|
|
44
|
+
const str = new import_magic_string.default(code);
|
|
45
|
+
const extensions = [
|
|
46
|
+
".ts",
|
|
47
|
+
".tsx",
|
|
48
|
+
".js",
|
|
49
|
+
".jsx"
|
|
50
|
+
];
|
|
51
|
+
await Promise.all(modules.map(async (module2) => {
|
|
52
|
+
if (!module2.name) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const { start, end } = module2;
|
|
56
|
+
let { name: name2 } = module2;
|
|
57
|
+
const { redirect: redirect2, asset } = compiler.config;
|
|
58
|
+
const { alias, style } = redirect2;
|
|
59
|
+
if (alias) {
|
|
60
|
+
let absoluteImportPath = matchPath ? matchPath(name2, void 0, void 0, extensions) : void 0;
|
|
61
|
+
for (const alias2 of Object.keys(aliasRecord)) {
|
|
62
|
+
if (name2.startsWith(`${alias2}/`)) {
|
|
63
|
+
absoluteImportPath = (0, import_path.join)(aliasRecord[alias2], name2.slice(alias2.length + 1));
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
if (name2 === alias2) {
|
|
67
|
+
absoluteImportPath = aliasRecord[alias2];
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (absoluteImportPath) {
|
|
72
|
+
const relativePath = (0, import_path.relative)((0, import_path.dirname)(filePath), absoluteImportPath);
|
|
73
|
+
const relativeImportPath = (0, import_utils2.normalizeSlashes)(relativePath.startsWith("..") ? relativePath : `./${relativePath}`);
|
|
74
|
+
str.overwrite(start, end, relativeImportPath);
|
|
75
|
+
name2 = relativeImportPath;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (style) {
|
|
79
|
+
const ext = (0, import_path.extname)(name2);
|
|
80
|
+
const { originalFilePath, query } = (0, import_utils2.resolvePathAndQuery)(name2);
|
|
81
|
+
if (query.css_virtual) {
|
|
82
|
+
const replacedName = (0, import_path.basename)(originalFilePath, (0, import_path.extname)(originalFilePath)).replace(".", "_");
|
|
83
|
+
const base = `${replacedName}.css`;
|
|
84
|
+
const key = query.hash;
|
|
85
|
+
const contents = compiler.virtualModule.get(key);
|
|
86
|
+
const fileName = (0, import_path.join)(outputDir, base);
|
|
87
|
+
compiler.emitAsset(fileName, {
|
|
88
|
+
type: "asset",
|
|
89
|
+
contents,
|
|
90
|
+
fileName,
|
|
91
|
+
originalFileName: name2
|
|
92
|
+
});
|
|
93
|
+
const relativeImportPath = (0, import_utils2.normalizeSlashes)(`./${base}`);
|
|
94
|
+
str.overwrite(start, end, relativeImportPath);
|
|
95
|
+
}
|
|
96
|
+
if (!name2.startsWith(".")) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (ext === ".less" || ext === ".sass" || ext === ".scss" || ext === ".css") {
|
|
100
|
+
var _compiler_config_style_autoModules;
|
|
101
|
+
if ((0, import_postcssTransformer.isCssModule)(name2, (_compiler_config_style_autoModules = compiler.config.style.autoModules) !== null && _compiler_config_style_autoModules !== void 0 ? _compiler_config_style_autoModules : true)) {
|
|
102
|
+
str.overwrite(start, end, `${name2.slice(0, -ext.length)}`);
|
|
103
|
+
} else {
|
|
104
|
+
str.overwrite(start, end, `${name2.slice(0, -ext.length)}.css`);
|
|
105
|
+
}
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (redirect2.asset) {
|
|
110
|
+
if (import_file.assetExt.filter((ext) => name2.endsWith(ext)).length) {
|
|
111
|
+
const absPath = (0, import_path.resolve)((0, import_path.dirname)(filePath), name2);
|
|
112
|
+
const svgrResult = await (0, import_asset.loadSvgr)(absPath, asset.svgr);
|
|
113
|
+
if (svgrResult) {
|
|
114
|
+
const ext = (0, import_path.extname)(name2);
|
|
115
|
+
const outputName = `${name2.slice(0, -ext.length)}.js`;
|
|
116
|
+
str.overwrite(start, end, outputName);
|
|
117
|
+
} else {
|
|
118
|
+
const { contents: relativeImportPath } = await import_asset.getAssetContents.apply(compiler, [
|
|
119
|
+
absPath,
|
|
120
|
+
outputDir
|
|
121
|
+
]);
|
|
122
|
+
str.overwrite(start, end, `${relativeImportPath}`);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}));
|
|
127
|
+
return str;
|
|
128
|
+
}
|
|
129
|
+
const name = "redirect";
|
|
130
|
+
const redirect = {
|
|
131
|
+
name,
|
|
132
|
+
apply(compiler) {
|
|
133
|
+
let matchPath;
|
|
134
|
+
if (import_utils.fs.existsSync(compiler.config.tsconfig)) {
|
|
135
|
+
const result = (0, import_tsconfig_paths.loadConfig)(compiler.config.tsconfig);
|
|
136
|
+
if (result.resultType === "success") {
|
|
137
|
+
const { absoluteBaseUrl, paths, mainFields, addMatchAll } = result;
|
|
138
|
+
matchPath = (0, import_tsconfig_paths.createMatchPath)(absoluteBaseUrl, paths, mainFields, addMatchAll);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
compiler.hooks.transform.tapPromise({
|
|
142
|
+
name
|
|
143
|
+
}, async (args) => {
|
|
144
|
+
if (!(0, import_utils2.isJsExt)(args.path) && !(0, import_utils2.isJsLoader)(args.loader)) {
|
|
145
|
+
return args;
|
|
146
|
+
}
|
|
147
|
+
const { code, path: id } = args;
|
|
148
|
+
const { format, alias, sourceDir, outDir } = compiler.config;
|
|
149
|
+
if (!code || format === "iife" || format === "umd") {
|
|
150
|
+
return args;
|
|
151
|
+
}
|
|
152
|
+
const absoluteAlias = Object.entries(alias).reduce((result, [name2, target]) => {
|
|
153
|
+
if (!(0, import_path.isAbsolute)(target)) {
|
|
154
|
+
result[name2] = (0, import_path.resolve)(compiler.context.root, target);
|
|
155
|
+
} else {
|
|
156
|
+
result[name2] = target;
|
|
157
|
+
}
|
|
158
|
+
return result;
|
|
159
|
+
}, {});
|
|
160
|
+
let matchModule = [];
|
|
161
|
+
try {
|
|
162
|
+
const sgNode = import_napi.js.parse(code).root();
|
|
163
|
+
const funcPattern = [
|
|
164
|
+
`require($MATCH)`,
|
|
165
|
+
`import($MATCH)`
|
|
166
|
+
];
|
|
167
|
+
const staticPattern = [
|
|
168
|
+
`import $$VAR from '$MATCH'`,
|
|
169
|
+
`import $$VAR from "$MATCH"`,
|
|
170
|
+
`import '$MATCH'`,
|
|
171
|
+
`import "$MATCH"`
|
|
172
|
+
];
|
|
173
|
+
const funcMatchModule = funcPattern.map((p) => {
|
|
174
|
+
return sgNode.findAll(p);
|
|
175
|
+
}).flat().map((node) => {
|
|
176
|
+
const matchNode = node.getMatch("MATCH");
|
|
177
|
+
return {
|
|
178
|
+
name: matchNode.text().slice(1, -1),
|
|
179
|
+
start: matchNode.range().start.index + 1,
|
|
180
|
+
end: matchNode.range().end.index - 1
|
|
181
|
+
};
|
|
182
|
+
});
|
|
183
|
+
const staticMatchModule = staticPattern.map((p) => sgNode.findAll(p)).flat().map((node) => {
|
|
184
|
+
const matchNode = node.getMatch("MATCH");
|
|
185
|
+
return {
|
|
186
|
+
name: matchNode.text(),
|
|
187
|
+
start: matchNode.range().start.index,
|
|
188
|
+
end: matchNode.range().end.index
|
|
189
|
+
};
|
|
190
|
+
});
|
|
191
|
+
matchModule = [
|
|
192
|
+
...funcMatchModule,
|
|
193
|
+
...staticMatchModule
|
|
194
|
+
];
|
|
195
|
+
} catch (e) {
|
|
196
|
+
import_utils.logger.error("[parse error]", e);
|
|
197
|
+
}
|
|
198
|
+
if (!matchModule.length) {
|
|
199
|
+
return args;
|
|
200
|
+
}
|
|
201
|
+
const outputPath = (0, import_path.resolve)(outDir, (0, import_path.relative)(sourceDir, id));
|
|
202
|
+
const str = await redirectImport(compiler, code, matchModule, absoluteAlias, id, (0, import_path.dirname)(outputPath), matchPath);
|
|
203
|
+
return {
|
|
204
|
+
...args,
|
|
205
|
+
code: str.toString(),
|
|
206
|
+
map: str.generateMap({
|
|
207
|
+
hires: true,
|
|
208
|
+
includeContent: true
|
|
209
|
+
})
|
|
210
|
+
};
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
215
|
+
0 && (module.exports = {
|
|
216
|
+
redirect
|
|
217
|
+
});
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
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) => {
|
|
9
|
+
for (var name2 in all)
|
|
10
|
+
__defProp(target, name2, { get: all[name2], 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 });
|
|
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 style_exports = {};
|
|
30
|
+
__export(style_exports, {
|
|
31
|
+
css: () => css
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(style_exports);
|
|
34
|
+
var import_fs = require("fs");
|
|
35
|
+
var import_safe_identifier = require("safe-identifier");
|
|
36
|
+
var import_utils = require("../../../utils");
|
|
37
|
+
var import_transformStyle = require("./transformStyle");
|
|
38
|
+
const name = "css";
|
|
39
|
+
const css = {
|
|
40
|
+
name,
|
|
41
|
+
apply(compiler) {
|
|
42
|
+
compiler.hooks.load.tapPromise({
|
|
43
|
+
name
|
|
44
|
+
}, async (args) => {
|
|
45
|
+
if ((0, import_utils.isStyleExt)(args.path)) {
|
|
46
|
+
const { query } = (0, import_utils.resolvePathAndQuery)(args.path);
|
|
47
|
+
if (query === null || query === void 0 ? void 0 : query.css_virtual) {
|
|
48
|
+
const key = query.hash;
|
|
49
|
+
const contents = compiler.virtualModule.get(key);
|
|
50
|
+
return {
|
|
51
|
+
contents,
|
|
52
|
+
loader: "css"
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
contents: (0, import_fs.readFileSync)(args.path),
|
|
57
|
+
loader: "css"
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
compiler.hooks.transform.tapPromise({
|
|
62
|
+
name
|
|
63
|
+
}, async (source) => {
|
|
64
|
+
if ((0, import_utils.isStyleExt)(source.path)) {
|
|
65
|
+
let { code, loader = "css" } = source;
|
|
66
|
+
const { query } = (0, import_utils.resolvePathAndQuery)(source.path);
|
|
67
|
+
if (!(query === null || query === void 0 ? void 0 : query.css_virtual)) {
|
|
68
|
+
({ code, loader } = await import_transformStyle.transformStyle.apply(compiler, [
|
|
69
|
+
source
|
|
70
|
+
]));
|
|
71
|
+
}
|
|
72
|
+
const { style, buildType } = compiler.config;
|
|
73
|
+
if (style.inject && buildType === "bundle" && loader === "css") {
|
|
74
|
+
const styleInjectPath = require.resolve("style-inject/dist/style-inject.es").replace(/[\\/]+/g, "/");
|
|
75
|
+
const cssVariableName = (0, import_safe_identifier.identifier)("css", true);
|
|
76
|
+
code = `var ${cssVariableName} = ${JSON.stringify(code)};
|
|
77
|
+
import styleInject from '${styleInjectPath}';
|
|
78
|
+
styleInject(${cssVariableName});`;
|
|
79
|
+
loader = "js";
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
...source,
|
|
83
|
+
code,
|
|
84
|
+
loader
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
return source;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
92
|
+
0 && (module.exports = {
|
|
93
|
+
css
|
|
94
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ICompiler } from '../../../types';
|
|
2
|
+
interface Options {
|
|
3
|
+
compiler: ICompiler;
|
|
4
|
+
stdinDir: string;
|
|
5
|
+
}
|
|
6
|
+
export default class LessAliasesPlugin {
|
|
7
|
+
compiler: ICompiler;
|
|
8
|
+
stdinDir: string;
|
|
9
|
+
constructor(options: Options);
|
|
10
|
+
install(less: any, pluginManager: any): void;
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
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) => {
|
|
9
|
+
for (var name in all)
|
|
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 });
|
|
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 lessAliasPlugin_exports = {};
|
|
30
|
+
__export(lessAliasPlugin_exports, {
|
|
31
|
+
default: () => LessAliasesPlugin
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(lessAliasPlugin_exports);
|
|
34
|
+
var import_define_property = require("@swc/helpers/_/_define_property");
|
|
35
|
+
var import_fs = __toESM(require("fs"));
|
|
36
|
+
var import_utils = require("./utils");
|
|
37
|
+
class LessAliasesPlugin {
|
|
38
|
+
install(less, pluginManager) {
|
|
39
|
+
const getResolve = (filename, currentDirectory) => {
|
|
40
|
+
return this.compiler.css_resolve(filename, currentDirectory || this.stdinDir);
|
|
41
|
+
};
|
|
42
|
+
class AliasPlugin extends less.FileManager {
|
|
43
|
+
async loadFile(filename, currentDirectory) {
|
|
44
|
+
const resolved = getResolve(filename, currentDirectory);
|
|
45
|
+
const rebasedContents = await (0, import_utils.rebaseUrls)(resolved, this.stdinDir, this.compiler.css_resolve);
|
|
46
|
+
const contents = rebasedContents.contents ? rebasedContents.contents : import_fs.default.readFileSync(resolved, "utf8");
|
|
47
|
+
return {
|
|
48
|
+
filename: resolved,
|
|
49
|
+
contents
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
constructor(options) {
|
|
53
|
+
super();
|
|
54
|
+
(0, import_define_property._)(this, "compiler", void 0);
|
|
55
|
+
this.compiler = options.compiler;
|
|
56
|
+
this.stdinDir = options.stdinDir;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
pluginManager.addFileManager(new AliasPlugin({
|
|
60
|
+
compiler: this.compiler,
|
|
61
|
+
stdinDir: this.stdinDir
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
64
|
+
constructor(options) {
|
|
65
|
+
(0, import_define_property._)(this, "compiler", void 0);
|
|
66
|
+
(0, import_define_property._)(this, "stdinDir", void 0);
|
|
67
|
+
this.compiler = options.compiler;
|
|
68
|
+
this.stdinDir = options.stdinDir;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
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) => {
|
|
9
|
+
for (var name in all)
|
|
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 });
|
|
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 lessRender_exports = {};
|
|
30
|
+
__export(lessRender_exports, {
|
|
31
|
+
lessRender: () => lessRender
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(lessRender_exports);
|
|
34
|
+
var import_utils = require("./utils");
|
|
35
|
+
var import_lessAliasPlugin = __toESM(require("./lessAliasPlugin"));
|
|
36
|
+
const lessRender = async function(content, originPath, stdinDir, options, _, implementation) {
|
|
37
|
+
const less = await (0, import_utils.loadProcessor)("less", this.context.root, implementation);
|
|
38
|
+
const result = {
|
|
39
|
+
...await less.render(content, {
|
|
40
|
+
relativeUrls: true,
|
|
41
|
+
filename: originPath,
|
|
42
|
+
...options,
|
|
43
|
+
paths: [
|
|
44
|
+
...(options === null || options === void 0 ? void 0 : options.paths) || [
|
|
45
|
+
"node_modules"
|
|
46
|
+
],
|
|
47
|
+
this.context.root,
|
|
48
|
+
stdinDir
|
|
49
|
+
],
|
|
50
|
+
plugins: [
|
|
51
|
+
new import_lessAliasPlugin.default({
|
|
52
|
+
compiler: this,
|
|
53
|
+
stdinDir
|
|
54
|
+
}),
|
|
55
|
+
...(options === null || options === void 0 ? void 0 : options.plugins) || []
|
|
56
|
+
]
|
|
57
|
+
})
|
|
58
|
+
};
|
|
59
|
+
return result;
|
|
60
|
+
};
|
|
61
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
62
|
+
0 && (module.exports = {
|
|
63
|
+
lessRender
|
|
64
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ICompiler } from '../../../types';
|
|
2
|
+
export declare const isCssModule: (filePath: string, autoModules: boolean | RegExp) => boolean;
|
|
3
|
+
export declare const postcssTransformer: (css: string, entryPath: string, compilation: ICompiler) => Promise<{
|
|
4
|
+
code: string;
|
|
5
|
+
loader: 'js' | 'css';
|
|
6
|
+
}>;
|