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

transpile import.meta.url #21

Closed
FloEdelmann opened this issue Feb 18, 2021 · 2 comments
Closed

transpile import.meta.url #21

FloEdelmann opened this issue Feb 18, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@FloEdelmann
Copy link

I have set "type": "module" in package.json.

I use import.meta.url in nuxt.config.js and in another ES module that is referenced from nuxt.config.js. That other module is also called by Node.js directly, so I can't just use __filename or __dirname instead.

I suggest transpiling import.meta.url to 'file://' + __filename in Jiti to support this case.

@pi0 pi0 changed the title Cannot use 'import.meta' outside a module transpile import.meta.url Feb 18, 2021
@pi0 pi0 added the enhancement New feature or request label Feb 18, 2021
@linqFR
Copy link

linqFR commented Feb 28, 2021

I do not know what the right solution is, but obviously struggling with commonjs is starting to be a real pain !

Till a version of nuxt deals with that, is there any workaround ? (I wish not to rewrite modules to import)

thanks

@pi0 pi0 closed this as completed in d071704 Mar 3, 2021
@pi0
Copy link
Member

pi0 commented Mar 3, 2021

Hi. jiti@1.6.0 supports import.meta.url now. Best way to update for nuxt is recreating yarn.lock/package.lock.json file

@linqFR You can set createRequire inside nuxt.config to native if for any reason but i don't recommand that. Please report any other issues encountered to nuxt repository so we can address :)

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

No branches or pull requests

3 participants