Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(vite-node): deps.inline doesn't work (#3485)
  • Loading branch information
sheremet-va committed Jun 1, 2023
1 parent 29a37cd commit be93032
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/vite-node/src/externalize.ts
Expand Up @@ -139,7 +139,7 @@ function matchExternalizePattern(id: string, moduleDirectories: string[], patter
return true
for (const ex of patterns) {
if (typeof ex === 'string') {
if (moduleDirectories.some(dir => id.includes(join(dir, id))))
if (moduleDirectories.some(dir => id.includes(join(dir, ex))))
return true
}
else {
Expand Down
4 changes: 4 additions & 0 deletions test/core/projects/inline-lib/index.js
@@ -0,0 +1,4 @@
export default function () {
// module doesn't exist in Node.js ESM, but exists in vite-node
return typeof module
}
4 changes: 4 additions & 0 deletions test/core/projects/inline-lib/package.json
@@ -0,0 +1,4 @@
{
"type": "module",
"main": "index.js"
}
7 changes: 7 additions & 0 deletions test/core/test/inlined.test.ts
@@ -0,0 +1,7 @@
// @ts-expect-error not typed lib
import typeOfModule from 'inline-lib'
import { expect, test } from 'vitest'

test('inline lib has exports injected even though it is ESM', () => {
expect(typeOfModule()).toBe('object')
})
2 changes: 2 additions & 0 deletions test/core/vitest.config.ts
Expand Up @@ -36,6 +36,7 @@ export default defineConfig({
{ find: '#', replacement: resolve(__dirname, 'src') },
{ find: '$', replacement: 'src' },
{ find: /^custom-lib$/, replacement: resolve(__dirname, 'projects', 'custom-lib') },
{ find: /^inline-lib$/, replacement: resolve(__dirname, 'projects', 'inline-lib') },
],
},
test: {
Expand Down Expand Up @@ -63,6 +64,7 @@ export default defineConfig({
},
deps: {
external: ['tinyspy', /src\/external/],
inline: ['inline-lib'],
moduleDirectories: ['node_modules', 'projects', 'packages'],
},
alias: [
Expand Down

0 comments on commit be93032

Please sign in to comment.