esbuild `import.meta` warning
See original GitHub issueBug 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
npx create-snowpack-app my-app --template @snowpack/app-template-sveltecd my-app- Set
optimize.targetto'es2019'insnowpack.config.js 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:
- Created 3 years ago
- Reactions:5
- Comments:5 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
In that
esbuildthread someone requested the ability to disable thisimport.metabehavior specifically, which would fix this. I think it’s probably best handled upstream. Webpack 5 is starting to rely onimport.metaas 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
esbuildwarnings and only surfacing errors. Not sure if we want to do that.Makes sense, thanks for explaining. Feel free to close this issue if that’s preferred