Skip to content

fix: fix scoped modules exclusion on windows #2379

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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