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

Using inject with target=es6 -> export error #3343

Closed
Le0Developer opened this issue Aug 25, 2023 · 2 comments
Closed

Using inject with target=es6 -> export error #3343

Le0Developer opened this issue Aug 25, 2023 · 2 comments

Comments

@Le0Developer
Copy link

I'm trying to use inject to shim some functions while targeting es6, but I am getting the following error due to the export { fn as name } syntax:
Using a string as a module namespace identifier name is not supported in the configured target environment ("es2015")

Playground reproduction using the process.cwd example shim from the docs. Removing target=es6 from the compiler options makes it build as expected.

I've been trying alternatives (such as export default { name: fn }, module.exports = { name: fn }) but using them causes esbuild to not use the shim. (export let name = fn does work, however the name cannot contain dots in that case).

Any advice would be appreciated 🙏

@hyrious
Copy link

hyrious commented Aug 25, 2023

There was a way to inject a.b like things with --define:process.cwd=__process_cwd.

@Le0Developer
Copy link
Author

This feels more like a work-around than a proper solution I'm looking for, as it requires me to duplicate all shims into the build options.

@evanw evanw closed this as completed in 516ca31 May 24, 2024
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

No branches or pull requests

2 participants