Skip to content

Commit

Permalink
fix: not compile some deps (#641)
Browse files Browse the repository at this point in the history
  • Loading branch information
luhc228 authored Mar 28, 2024
1 parent 65aaa99 commit 1203622
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/pkg/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ export function getIncludeNodeModuleScripts(compileDependencies: boolean | Array
// will not match:
// node_modules/abc/node_modules/def/index.js
// node_modules/def/index.js
return [new RegExp(`node_modules/(${compileDependencies.map((dep: string | RegExp) => (`${typeof dep === 'string' ? dep : dep.source}`)).join('|')})/(?!node_modules/)[^\\/]+.(?:[cm]?[jt]s|[jt]sx)$`)];
return [new RegExp(`node_modules/(${compileDependencies.map((dep: string | RegExp) => (`${typeof dep === 'string' ? dep : dep.source}`)).join('|')})/(?!node_modules/).*.(?:[cm]?[jt]s|[jt]sx)$`)];
}
// default
return [];
Expand Down
2 changes: 2 additions & 0 deletions packages/pkg/tests/createScriptsFilter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,14 @@ test('createScriptsFilter with some compileDependencies', async () => {
expect(scriptsFilter('/w/node_modules/@ice/runtime/node_modules/@ice/app/a.js')).toBe(true);
expect(scriptsFilter('/w/node_modules/@ice/app/node_modules/rax-compat/index.js')).toBe(false);
expect(scriptsFilter('/w/node_modules/lodash/node_modules/rax-compat/index.js')).toBe(false);
expect(scriptsFilter('/w/node_modules/lodash/node_modules/rax-compat/dist/index.js')).toBe(false);
// Windows path
expect(scriptsFilter('C:\\w\\node_modules\\lodash\\a.js')).toBe(true);
expect(scriptsFilter('C:\\w\\node_modules\\@ice\\app\\a.js')).toBe(true);
expect(scriptsFilter('C:\\w\\node_modules\\@ice\\runtime\\node_modules\\lodash\\a.js')).toBe(true);
expect(scriptsFilter('C:\\w\\node_modules\\@ice\\runtime\\node_modules\\@ice\\app\\a.js')).toBe(true);
expect(scriptsFilter('C:\\w\\node_modules\\@ice\\app\\node_modules\\rax-compat\\index.js')).toBe(false);
expect(scriptsFilter('C:\\w\\node_modules\\@ice\\app\\node_modules\\rax-compat\\dist\\index.js')).toBe(false);

// default exclude some deps
expect(scriptsFilter('/w/node_modules/@babel/runtime/a.js')).toBe(false);
Expand Down

0 comments on commit 1203622

Please sign in to comment.