question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 4 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
jkremscommented, Nov 22, 2019

I propose we add import.meta.hot as a replacement for module.hot.

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).

0reactions
mischniccommented, Dec 22, 2020

Vite does use import.meta.env instead of process.env

Read more comments on GitHub >

github_iconTop Results From Across the Web

JavaScript - Parcel
The import.meta object includes information about the module it is referenced in. Parcel currently supports a single property, import.meta.url , which ...
Read more >
import.meta - JavaScript - MDN Web Docs
The import.meta meta-property exposes context-specific metadata to a JavaScript module. It contains information about the module, ...
Read more >
babel-plugin-bundled-import-meta | Yarn - Package Manager
Babel plugin to rewrite import.meta.url for use in bundles. Install babel-plugin-bundled-import-meta. This module requires node.js 8 or above ...
Read more >
uncaught syntaxerror: import.meta may only appear in a module
Additionally, not all browsers support ESM yet. ... Uncaught SyntaxError: Cannot use 'import.meta' outside a module - Nx Monorepo ... Parcel, 2.0.1.
Read more >
rollup.js
Importing CommonJS · Publishing ES Modules ... Use import.meta.url to make the path relative to the current source file instead of process.cwd() //...
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