You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Open Stackblitz repro
Observe the test function in app.vue : it has a console.log that works fine in dev mode (yarn dev)
What is Expected?
App should build successfully
What is actually happening?
Build fails with Unexpected token (Note that you need plugins to import files that are not JavaScript)
Another variant can also happen in ts files : [vite:build-import-analysis] Parse error @:1:1
I'm not providing a repro because it would be too long to set up, but screenshot below on a Pinia store file:
Bug Analysis
The bug happens when console.log is removed from a lambda void-returning arrow-syntax function with a single instruction.
I guess the parser is a bit too aggressive and transforms :
const test = () => console.log('Test')
Into
const test = () =>
Which is invalid Javascript
Solution
This is not a Nuxt-Security bug, this comes from unplugin-remove
Version
nuxt-security: 1.0.0-rc.4
nuxt: 3.8.2
Reproduction Link
https://stackblitz.com/edit/nuxt-starter-tsqs5c?file=README.md
Steps to reproduce
Open Stackblitz repro
Observe the
test
function inapp.vue
: it has aconsole.log
that works fine in dev mode (yarn dev
)What is Expected?
App should build successfully
What is actually happening?
Build fails with
Unexpected token (Note that you need plugins to import files that are not JavaScript)
Another variant can also happen in
ts
files :[vite:build-import-analysis] Parse error @:1:1
I'm not providing a repro because it would be too long to set up, but screenshot below on a Pinia
store
file:Bug Analysis
The bug happens when
console.log
is removed from a lambda void-returning arrow-syntax function with a single instruction.I guess the parser is a bit too aggressive and transforms :
Into
Which is invalid Javascript
Solution
This is not a Nuxt-Security bug, this comes from
unplugin-remove
Upstream Issue opened at : Talljack/unplugin-remove#3
Temporary Solution for Nuxt-Security : If you encounter this issue, you can either :
removeLoggers: false
const test = () => { console.log('Test') }
The text was updated successfully, but these errors were encountered: