diff --git a/packages/pkg/src/utils.ts b/packages/pkg/src/utils.ts index 7216c1a5..83389b24 100644 --- a/packages/pkg/src/utils.ts +++ b/packages/pkg/src/utils.ts @@ -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 []; diff --git a/packages/pkg/tests/createScriptsFilter.test.ts b/packages/pkg/tests/createScriptsFilter.test.ts index 168ee2cc..de6555cb 100644 --- a/packages/pkg/tests/createScriptsFilter.test.ts +++ b/packages/pkg/tests/createScriptsFilter.test.ts @@ -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);