-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[plugin] When return contents, the output path does not meet the expected result #864
Comments
In addition, I want to export through the build.onLoad({ filter: /.*/, namespace: 'transform' }, async (args) => {
return {
contents: `export * from "${args.path}";import m from "${args.path}";export default m;`,
resolveDir: process.cwd()
}
}) Build and after running: import React,{ useState } from "./packages/react.js"
^^^^^^^^
SyntaxError: The requested module './packages/react.js' does not provide an export named 'useState' |
@evanw How can I solve the above problems? |
It's probably not possible to solve this yet with a single run of esbuild and no other code. One option is to run esbuild multiple times (once for each entry point) and use Closing as a duplicate of #442 for somehow automatically exporting all keys from a CommonJS module as named exports and as a duplicate of #553 for being able to override the output file path of specific output files. |
This is feasible, but it cannot enjoy the benefits of splitting, which is not a good solution.
This seems a bit clumsy, it still has a problem: output files share the same path but have different contentsSuppose I execute the following build: require('esbuild').build({
format: 'esm',
entryPoints: [
'react-dom/server',
'react-router-dom/server',
],
....
}) It will throw an error: output files share the same path but have different contents: server.js The #553 is a very good solution, and I look forward to its early realization. |
@evanw
I try to convert commonjs to esm:
It works well, but the output path is not the expected result.
expected output path:
Current output path:
The same question appears in #744 , but there is no answer.
The description about
contents
in the esbuild doc:This seems to be the cause of the problem.
The text was updated successfully, but these errors were encountered: