mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 08:02:01 +00:00
feat: Process transpile path (#4335)
This commit is contained in:
parent
e21301f9b0
commit
ae8dc96669
@ -2,6 +2,7 @@ import path from 'path'
|
||||
import fs from 'fs'
|
||||
import defaultsDeep from 'lodash/defaultsDeep'
|
||||
import defaults from 'lodash/defaults'
|
||||
import escapeRegExp from 'lodash/escapeRegExp'
|
||||
import pick from 'lodash/pick'
|
||||
import isObject from 'lodash/isObject'
|
||||
import consola from 'consola'
|
||||
@ -320,7 +321,16 @@ export function getNuxtConfig(_options) {
|
||||
|
||||
// include SFCs in node_modules
|
||||
options.build.transpile = [].concat(options.build.transpile || [])
|
||||
.map(module => module instanceof RegExp ? module : new RegExp(module))
|
||||
.map(module => (module instanceof RegExp)
|
||||
? module
|
||||
: new RegExp(
|
||||
escapeRegExp(
|
||||
path.normalize(
|
||||
module.replace(/\\/g, '/')
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
if (options.build.quiet === true) {
|
||||
consola.level = 0
|
||||
|
@ -1,3 +1,4 @@
|
||||
import path from 'path'
|
||||
import consola from 'consola'
|
||||
import { Builder, BundleBuilder, getPort, loadFixture, Nuxt, rp } from '../utils'
|
||||
|
||||
@ -26,7 +27,9 @@ describe('basic dev', () => {
|
||||
chunk: 'test-[name].[contenthash].js'
|
||||
},
|
||||
transpile: [
|
||||
'vue\\.test\\.js',
|
||||
'@scoped/packageA',
|
||||
'@scoped\\packageB',
|
||||
'vue.test.js',
|
||||
/vue-test/
|
||||
],
|
||||
loaders: {
|
||||
@ -60,10 +63,12 @@ describe('basic dev', () => {
|
||||
|
||||
test('Config: build.transpile', () => {
|
||||
expect(transpile('vue-test')).toBe(true)
|
||||
expect(transpile('node_modules/test.js')).toBe(false)
|
||||
expect(transpile('node_modules/vue-test')).toBe(true)
|
||||
expect(transpile('node_modules/vue.test.js')).toBe(true)
|
||||
expect(transpile('node_modules/test.vue.js')).toBe(true)
|
||||
expect(transpile(path.normalize('node_modules/test.js'))).toBe(false)
|
||||
expect(transpile(path.normalize('node_modules/vue-test'))).toBe(true)
|
||||
expect(transpile(path.normalize('node_modules/vue.test.js'))).toBe(true)
|
||||
expect(transpile(path.normalize('node_modules/test.vue.js'))).toBe(true)
|
||||
expect(transpile(path.normalize('node_modules/@scoped/packageA/src/index.js'))).toBe(true)
|
||||
expect(transpile(path.normalize('node_modules/@scoped/packageB/src/index.js'))).toBe(true)
|
||||
})
|
||||
|
||||
test('Config: build.filenames', () => {
|
||||
|
Loading…
Reference in New Issue
Block a user