esbuild `import.meta` warning

See original GitHub issue

Bug Report Quick Checklist

  • I am on the latest version of Snowpack & all plugins.
  • I use package manager npm
  • I run Snowpack on macOS
  • I run Snowpack on Node.js 12.20.1

Describe the bug

The HMR import.meta check causes this esbuild warning when targetting browsers that don’t support import.meta:

[snowpack] ! optimizing build...
 > dist/index.js:2:0: warning: "import.meta" is not available in the configured target environment and will be empty
    2 │ import.meta.env = __SNOWPACK_ENV__;
      ╵ ~~~~~~~~~~~

1 warning
[
  {
    detail: undefined,
    location: {
      column: 0,
      file: 'dist/index.js',
      length: 11,
      line: 2,
      lineText: 'import.meta.env = __SNOWPACK_ENV__;',
      namespace: ''
    },
    notes: [],
    text: '"import.meta" is not available in the configured target environment and will be empty'
  }
]

To Reproduce

  1. npx create-snowpack-app my-app --template @snowpack/app-template-svelte
  2. cd my-app
  3. Set optimize.target to 'es2019' in snowpack.config.js
  4. npm run build

Expected behavior

Ideally it should be possible to use HMR while building for browsers that don’t support import.meta without getting warnings

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:5
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
natemoo-recommented, Mar 18, 2021

In that esbuild thread someone requested the ability to disable this import.meta behavior specifically, which would fix this. I think it’s probably best handled upstream. Webpack 5 is starting to rely on import.meta as well, so this type of issue is only becoming more common.

If there’s anything we can do on our end, it would just be disabling esbuild warnings and only surfacing errors. Not sure if we want to do that.

0reactions
probablykaspercommented, Mar 18, 2021

Makes sense, thanks for explaining. Feel free to close this issue if that’s preferred

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error when transforming import.meta #349 - evanw/esbuild
When doing a single file transform using es2019 or below, esbuild throws a warning: "import.meta" is not available in the configured target ...
Read more >
API - esbuild
To join a set of files together with esbuild, import them all into a single entry point file and bundle just that one...
Read more >
Building: Rollup Plugin Import Meta Assets - Modern Web
By default, the plugin quits the build process when it encounters an error. If you set this option to true, it will throw...
Read more >
Build Options | Vite (main branch)
The transform is performed with esbuild and the value should be a valid ... import.meta.url is used at runtime to avoid absolute paths...
Read more >
Changelog - esbuild - Breword 文档集合
This is why esbuild previously generated warnings when it encountered unknown CSS ... However, it previously didn't work with import.meta because this is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found