Skip to content
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

Parsing of language file fails when using functions #1680

Open
5 tasks done
TheDutchCoder opened this issue Aug 1, 2023 · 1 comment
Open
5 tasks done

Parsing of language file fails when using functions #1680

TheDutchCoder opened this issue Aug 1, 2023 · 1 comment
Labels
Status: Review Needed Request for review comments

Comments

@TheDutchCoder
Copy link

TheDutchCoder commented Aug 1, 2023

Reporting a bug?

Consider the following two function calls:
locationName(named('pointOfInterest'), false)
locationName({ pointOfInterest: named('pointOfInterest'), includeParent: false })

With origin2:

export const locationName = ({ pointOfInterest, includeParent, abbreviatedParent = true }) => {
  // do something
}

The former can be used in a locale file and works fine, but the latter will fail parsing and will add part of the function call at the end of the parsed string:
image

Expected behavior

foo({ a: 'a' }) to be compiled correctly

Reproduction

Fiddle doesn't work ("Uncaught ReferenceError: VueI18n is not defined")

System Info

System:
    OS: macOS 13.4.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 374.34 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.16.1 - ~/.nvm/versions/node/v18.16.1/bin/node
    npm: 9.5.1 - ~/.nvm/versions/node/v18.16.1/bin/npm
  Browsers:
    Chrome: 115.0.5790.114
    Safari: 16.5.2
  npmPackages:
    vite-svg-loader: ^4.0.0 => 4.0.0

Screenshot

See main issue

Additional context

No response

Validations

@TheDutchCoder TheDutchCoder added the Status: Review Needed Request for review comments label Aug 1, 2023
@TheDutchCoder
Copy link
Author

TheDutchCoder commented Aug 1, 2023

It seems to be an even deeper issue, you can't use functions at all...

If I define the function in the file itself, vite crashes with a 500. It works if I remove the local function.
Imports also don't work (same 500 crash):

// import
import { someFunc } from '~/lib/someFunc` // This crashes Vite

// local
const someFunc = () => 'hello' // Calling this crashes Vite (someFunc is not defined).

export default {
  test: () => someFunc()
}

@TheDutchCoder TheDutchCoder changed the title Parsing of language file fails on function parameter destructuring Parsing of language file fails when using functions Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Review Needed Request for review comments
Projects
None yet
Development

No branches or pull requests

1 participant