Parcel support for import.meta
See original GitHub issue❔ Question
Are there any plans for Parcel to support the import.meta Javascript object in the near future? https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import.meta
🔦 Context
I have a requirement to use Javascript’s import.meta in my module code, which I then use to build a url string to download and start a web worker. My code is entirely ES6 modular.
💻 Code Sample
const buildFilterWorker = function () {
let path = import.meta.url.slice(0, -('factory/filter.js'.length))
let filterUrl = `${path}worker/filter.js`;
return new Worker(filterUrl);
};
Running Parcel leads to the following build error:
$ parcel index.html Server running at http://localhost:1234 🚨 factory/filter.js:191:19: Support for the experimental syntax ‘importMeta’ isn’t currently enabled (191:20): 189 | const buildFilterWorker = function () { 190 |
191 | let path = import.meta.url.slice(0, -(‘factory/filter.js’.length)) | ^
🌍 Your Environment
Software | Version(s) |
---|---|
Parcel | 1.12.3 |
Node | 12.6.0 |
npm/Yarn | npm 6.9.0 |
Operating System | MacOSX |
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (6 by maintainers)
I was about to open issue asking for that. Right now it doesn’t seem possible to write a valid ES module that also supports hot reload (because it needs to reference a “file-scoped”
module
).Vite does use
import.meta.env
instead ofprocess.env