Skip to content

Commit

Permalink
fix: fix scoped modules exclusion on windows (#2379)
Browse files Browse the repository at this point in the history
closes #2251
  • Loading branch information
haoqunjiang authored Sep 4, 2018
1 parent 33dad39 commit 3247719
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ beforeAll(async () => {
`const test = () => "__TEST__";\nexport default test`
)

await project.write(
'node_modules/@scope/external-dep/package.json',
`{ "name": "@scope/external-dep", "version": "1.0.0", "main": "index.js" }`
)

await project.write(
'node_modules/@scope/external-dep/index.js',
`const test = () => "__SCOPE_TEST__";\nexport default test`
)

let $packageJson = await project.read('package.json')

$packageJson = JSON.parse($packageJson)
Expand All @@ -39,7 +49,12 @@ beforeAll(async () => {

let $mainjs = await project.read('src/main.js')

$mainjs = `import test from 'external-dep'\n${$mainjs}\ntest()`
$mainjs = `
import test from 'external-dep'
import scopeTest from '@scope/external-dep'
${$mainjs}
test()
scopeTest()`

await project.write(
'src/main.js',
Expand All @@ -59,4 +74,6 @@ test('dep from node_modules should been transpiled', async () => {
)
await project.run('vue-cli-service build')
expect(await readVendorFile()).toMatch('return "__TEST__"')

expect(await readVendorFile()).toMatch('return "__SCOPE_TEST__"')
})
10 changes: 9 additions & 1 deletion packages/@vue/cli-plugin-babel/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const path = require('path')

module.exports = (api, options) => {
const useThreads = process.env.NODE_ENV === 'production' && options.parallel
const cliServicePath = require('path').dirname(require.resolve('@vue/cli-service'))
Expand All @@ -17,7 +19,13 @@ module.exports = (api, options) => {
return true
}
// check if this is something the user explicitly wants to transpile
if (options.transpileDependencies.some(dep => filepath.match(dep))) {
if (options.transpileDependencies.some(dep => {
if (typeof dep === 'string') {
return filepath.includes(path.normalize(dep))
} else {
return filepath.match(dep)
}
})) {
return false
}
// Don't transpile node_modules
Expand Down

0 comments on commit 3247719

Please sign in to comment.