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

[0.7.x] Polyfill import.meta.url for CJS builds #217

Merged
merged 1 commit into from
May 10, 2023
Merged

[0.7.x] Polyfill import.meta.url for CJS builds #217

merged 1 commit into from
May 10, 2023

Conversation

timacdonald
Copy link
Member

@timacdonald timacdonald commented May 9, 2023

__dirname is not supported in MJS.

import.meta.url to the rescue.

import.meta.url is not supported in CJS.

Sigh.

This PR migrates to using import.meta.url and polyfiling the CJS build with the more modern approach.

Read more about ES Modules and __dirname here: https://blog.logrocket.com/alternatives-dirname-node-js-es-modules/

The polyfill was taken from: evanw/esbuild#1633

Fixes #216

@taylorotwell taylorotwell merged commit 6c0d05a into laravel:main May 10, 2023
@timacdonald timacdonald deleted the polyfill branch May 10, 2023 23:47
@innocenzi
Copy link
Contributor

Just FYI, dedicated build tools like https://github.com/unjs/unbuild provide this feature out-of-the-box. 👍

I highly recommend using it instead of esbuild directly.

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

Successfully merging this pull request may close these issues.

__dirname is not defined
4 participants