mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 23:22:02 +00:00
fix(nuxt): only tree-shake composables on their own lines (#5850)
This commit is contained in:
parent
8685bfa9e9
commit
2d70507d1c
@ -10,17 +10,17 @@ interface TreeShakePluginOptions {
|
||||
}
|
||||
|
||||
export const TreeShakePlugin = createUnplugin((options: TreeShakePluginOptions) => {
|
||||
const COMPOSABLE_RE = new RegExp(`($|\\s+)(${options.treeShake.join('|')})(?=\\()`, 'gm')
|
||||
const COMPOSABLE_RE = new RegExp(`($\\s+)(${options.treeShake.join('|')})(?=\\()`, 'gm')
|
||||
|
||||
return {
|
||||
name: 'nuxt:server-treeshake:transfrom',
|
||||
enforce: 'post',
|
||||
transformInclude (id) {
|
||||
const { pathname, search } = parseURL(decodeURIComponent(pathToFileURL(id).href))
|
||||
const { type, macro } = parseQuery(search)
|
||||
const { type } = parseQuery(search)
|
||||
|
||||
// vue files
|
||||
if (pathname.endsWith('.vue') && (type === 'script' || macro || !search)) {
|
||||
if (pathname.endsWith('.vue') && (type === 'script' || !search)) {
|
||||
return true
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user