@umijs/bundler-esbuild 4.0.0-rc.1 → 4.0.0-rc.10
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.d.ts +3 -1
- package/dist/index.js +5 -1
- package/dist/plugins/less.d.ts +1 -1
- package/dist/plugins/less.js +24 -12
- package/package.json +9 -10
package/dist/build.d.ts
CHANGED
|
@@ -15,5 +15,7 @@ interface IOpts {
|
|
|
15
15
|
extraBabelPresets?: IBabelPlugin[];
|
|
16
16
|
inlineStyle?: boolean;
|
|
17
17
|
}
|
|
18
|
-
export declare function build(opts: IOpts): Promise<import("@umijs/bundler-utils/compiled/esbuild").BuildResult
|
|
18
|
+
export declare function build(opts: IOpts): Promise<import("@umijs/bundler-utils/compiled/esbuild").BuildResult & {
|
|
19
|
+
metafile: import("@umijs/bundler-utils/compiled/esbuild").Metafile;
|
|
20
|
+
}>;
|
|
19
21
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/dist/plugins/less.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/// <reference types="less" />
|
|
2
1
|
import { Plugin } from '@umijs/bundler-utils/compiled/esbuild';
|
|
3
2
|
import { IConfig } from '../types';
|
|
3
|
+
export declare const aliasLessImportPath: (filePath: string, alias: Record<string, string>, importer: string) => Promise<string | null>;
|
|
4
4
|
declare const _default: (options?: Less.Options & {
|
|
5
5
|
alias?: Record<string, string>;
|
|
6
6
|
inlineStyle?: boolean;
|
package/dist/plugins/less.js
CHANGED
|
@@ -23,9 +23,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
23
23
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.aliasLessImportPath = void 0;
|
|
27
|
+
const less_1 = __importDefault(require("@umijs/bundler-utils/compiled/less"));
|
|
26
28
|
const enhanced_resolve_1 = __importDefault(require("enhanced-resolve"));
|
|
27
29
|
const fs_1 = require("fs");
|
|
28
|
-
const less_1 = __importDefault(require("less"));
|
|
29
30
|
const less_plugin_aliases_1 = __importDefault(require("less-plugin-aliases"));
|
|
30
31
|
const path_1 = __importDefault(require("path"));
|
|
31
32
|
const postcssProcess_1 = require("../utils/postcssProcess");
|
|
@@ -59,7 +60,7 @@ const aliasLessImports = (ctx, alias, importer) => __awaiter(void 0, void 0, voi
|
|
|
59
60
|
const match = ctx.match(globalImportRegex) || [];
|
|
60
61
|
for (const el of match) {
|
|
61
62
|
const [imp, _, filePath] = el.match(importRegex) || [];
|
|
62
|
-
let aliaPath = yield aliasLessImportPath(filePath, alias, importer);
|
|
63
|
+
let aliaPath = yield (0, exports.aliasLessImportPath)(filePath, alias, importer);
|
|
63
64
|
if (aliaPath) {
|
|
64
65
|
ctx = ctx.replace(imp, el.replace(filePath, aliaPath));
|
|
65
66
|
}
|
|
@@ -73,16 +74,17 @@ const aliasLessImportPath = (filePath, alias, importer) => __awaiter(void 0, voi
|
|
|
73
74
|
: filePath;
|
|
74
75
|
const keys = (0, sortByAffix_1.sortByAffix)({ arr: Object.keys(alias), affix: '$' });
|
|
75
76
|
for (const key of keys) {
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
aliaPath =
|
|
77
|
+
const pathSegments = aliaPath.split('/');
|
|
78
|
+
if (pathSegments[0] === key) {
|
|
79
|
+
pathSegments[0] = alias[key];
|
|
80
|
+
aliaPath = pathSegments.join('/');
|
|
80
81
|
aliaPath = path_1.default.extname(aliaPath) ? aliaPath : `${aliaPath}.less`;
|
|
81
82
|
return yield resolve(importer, aliaPath);
|
|
82
83
|
}
|
|
83
84
|
}
|
|
84
85
|
return null;
|
|
85
86
|
});
|
|
87
|
+
exports.aliasLessImportPath = aliasLessImportPath;
|
|
86
88
|
exports.default = (options = {}) => {
|
|
87
89
|
const { alias, inlineStyle, config } = options, lessOptions = __rest(options, ["alias", "inlineStyle", "config"]);
|
|
88
90
|
return {
|
|
@@ -90,14 +92,24 @@ exports.default = (options = {}) => {
|
|
|
90
92
|
setup({ onResolve, onLoad }) {
|
|
91
93
|
onResolve({ filter: /\.less$/, namespace: 'file' }, (args) => __awaiter(this, void 0, void 0, function* () {
|
|
92
94
|
let filePath = args.path;
|
|
95
|
+
let isMatchedAlias = false;
|
|
96
|
+
// first match alias
|
|
93
97
|
if (!!alias) {
|
|
94
|
-
filePath
|
|
95
|
-
|
|
96
|
-
|
|
98
|
+
const aliasMatchPath = yield (0, exports.aliasLessImportPath)(filePath, alias, args.path);
|
|
99
|
+
if (aliasMatchPath) {
|
|
100
|
+
isMatchedAlias = true;
|
|
101
|
+
filePath = aliasMatchPath;
|
|
102
|
+
}
|
|
97
103
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
104
|
+
// if alias not matched, identify whether import from deps (node_modules)
|
|
105
|
+
if (!isMatchedAlias) {
|
|
106
|
+
const isImportFromDeps = !path_1.default.isAbsolute(filePath) && !filePath.startsWith('.');
|
|
107
|
+
if (isImportFromDeps) {
|
|
108
|
+
filePath = yield resolve(process.cwd(), filePath);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
filePath = path_1.default.resolve(process.cwd(), path_1.default.relative(process.cwd(), args.resolveDir), args.path);
|
|
112
|
+
}
|
|
101
113
|
}
|
|
102
114
|
return {
|
|
103
115
|
path: filePath,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/bundler-esbuild",
|
|
3
|
-
"version": "4.0.0-rc.
|
|
3
|
+
"version": "4.0.0-rc.10",
|
|
4
4
|
"description": "@umijs/bundler-esbuild",
|
|
5
5
|
"homepage": "https://github.com/umijs/umi-next/tree/master/packages/bundler-esbuild#readme",
|
|
6
6
|
"bugs": "https://github.com/umijs/umi-next/issues",
|
|
@@ -20,21 +20,20 @@
|
|
|
20
20
|
"scripts": {
|
|
21
21
|
"build": "pnpm tsc",
|
|
22
22
|
"build:deps": "pnpm esno ../../scripts/bundleDeps.ts",
|
|
23
|
-
"dev": "pnpm build -- --watch"
|
|
23
|
+
"dev": "pnpm build -- --watch",
|
|
24
|
+
"test": "jest -c ../../jest.turbo.config.ts"
|
|
24
25
|
},
|
|
25
26
|
"dependencies": {
|
|
26
|
-
"@umijs/bundler-utils": "4.0.0-rc.
|
|
27
|
-
"@umijs/utils": "4.0.0-rc.
|
|
28
|
-
"enhanced-resolve": "5.
|
|
29
|
-
"less": "4.1.2",
|
|
27
|
+
"@umijs/bundler-utils": "4.0.0-rc.10",
|
|
28
|
+
"@umijs/utils": "4.0.0-rc.10",
|
|
29
|
+
"enhanced-resolve": "5.9.2",
|
|
30
30
|
"less-plugin-aliases": "^1.0.3",
|
|
31
|
-
"postcss": "^8.4.
|
|
31
|
+
"postcss": "^8.4.12",
|
|
32
32
|
"postcss-flexbugs-fixes": "5.0.2",
|
|
33
|
-
"postcss-preset-env": "7.
|
|
33
|
+
"postcss-preset-env": "7.4.3"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@alitajs/postcss-plugin-px2rem": "^0.0.1"
|
|
37
|
-
"@types/less": "^3.0.3"
|
|
36
|
+
"@alitajs/postcss-plugin-px2rem": "^0.0.1"
|
|
38
37
|
},
|
|
39
38
|
"publishConfig": {
|
|
40
39
|
"access": "public"
|