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

Fix: don't crash the build if env var passed to define is undefined #6

Open
webketje opened this issue Aug 25, 2023 · 0 comments
Open

Comments

@webketje
Copy link
Member

When a ms build is run like so

metalsmith
  .env('NODE_ENV', undefined)
  .use(jsBundle())

esbuild throws an error, halting the MS build

▲ [WARNING] "process.env.NODE_ENV" is defined as an identifier instead of a string (surround "undefined" with quotes to get a string) [suspicious-define]

    <js>:1:34:
      1 │ define: { 'process.env.NODE_ENV': 'undefined' }
        │                                   ~~~~~~~~~~~
        ╵                                   '"undefined"'

This may be desirable when the define option is explicitly set, but is definitely unexpected when it's not. Solution is to replace the undefined value with the string undefined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant