Skip to content

Commit 49bedb9

Browse files
authored
fix: should not escape windows path when use transformLodash (#6910)
1 parent 8cd4ab0 commit 49bedb9

File tree

6 files changed

+80
-14
lines changed

6 files changed

+80
-14
lines changed

.changeset/grumpy-cherries-end.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@modern-js/uni-builder': patch
3+
---
4+
5+
fix: should not escape windows path when use transformLodash

packages/cli/uni-builder/compiled/babel-plugin-lodash/index.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-lock.yaml

+46-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/prebundle/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"@types/signale": "1.4.7",
4040
"@types/url-join": "4.0.3",
4141
"address": "1.2.2",
42+
"babel-plugin-lodash": "3.3.4",
4243
"browserslist": "4.24.4",
4344
"chalk": "4.1.2",
4445
"chokidar": "3.6.0",

scripts/prebundle/src/constant.ts

+26
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,32 @@ export const TASKS: TaskConfig[] = [
128128
},
129129
],
130130
},
131+
{
132+
packageDir: 'cli/uni-builder',
133+
packageName: '@modern-js/uni-builder',
134+
dependencies: [
135+
{
136+
name: 'babel-plugin-lodash',
137+
ignoreDts: true,
138+
externals: {
139+
// should keep glob v7 (windowsPathsNoEscape by default)
140+
glob: '@modern-js/utils/glob',
141+
},
142+
// Fix the deprecated babel API
143+
// https://github.com/lodash/babel-plugin-lodash/issues/259
144+
// https://github.com/lodash/babel-plugin-lodash/pull/261
145+
beforeBundle(task) {
146+
const mainFile = join(task.depPath, 'lib/index.js');
147+
replaceFileContent(mainFile, content => {
148+
return content.replace(
149+
'(0, _types.isModuleDeclaration)(node)',
150+
'(0, _types.isImportDeclaration)(node) || (0, _types.isExportDeclaration)(node)',
151+
);
152+
});
153+
},
154+
},
155+
],
156+
},
131157
{
132158
// Todo: rename
133159
packageDir: 'solutions/module-tools',

tests/integration/transform-lodash-import/tests/index.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { modernBuild } from '../../../utils/modernTestUtils';
33

44
const appDir = path.resolve(__dirname, '../');
55

6-
describe.skip('test both source.transformImport and performance.transformLodash to handle lodash', () => {
6+
describe('test both source.transformImport and performance.transformLodash to handle lodash', () => {
77
let buildRes: { stdout: string };
88
beforeAll(async () => {
99
buildRes = await modernBuild(appDir);

0 commit comments

Comments
 (0)