-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add entryPoint field to args of onLoad callback #873
Comments
since esbuild already supports plugindata, i think you can put entryPoint in pluginData yourself https://github.com/evanw/esbuild/blob/master/CHANGELOG.md#0838 |
@hardfist Thanks. I know this, but cannot match {
path: 'react',
importer: 'react',
namespace: 'transform',
resolveDir: '/Volumes/private/github/package',
pluginData: undefined
}
....
{
path: './cjs/react.development.js',
importer: '/Volumes/private/github/package/node_modules/react/index.js',
namespace: 'file',
resolveDir: '/Volumes/private/github/package/node_modules/react',
pluginData: undefined
} The |
you can save origin entrypath in plugindata in resolve hooks,then it will carry the origin path to onload hooks by plugindata |
@hardfist Can you provide sample code? I know that parameters can be passed between plugins through plugindata, but the origin entryPoint already exists, there is no need to pass it.
I need to collect the real entryPoint of the module through the first build. This is what i want:{
"react": '/Volumes/private/github/package/node_modules/react/index.js',
"react-dom": '/Volumes/private/github/package/node_modules/react-dom/index.js',
"react-dom/server": '/Volumes/private/github/package/node_modules/react-dom/server.browser.js'
} But in onLoad or onResolve, the // onResolve args
{
path: 'react',
importer: '',
namespace: '',
resolveDir: '/Volumes/private/github/package',
pluginData: undefined
}
// onLoad args,
{
path: 'react',
namespace: 'transform',
pluginData: undefined
} Cannot match the |
@pandagood I know that this isn't specifically what you want but a work-around might be to use the clever hack proposed here to explicitly resolve the entrypoint using esbuild: #814 (comment). |
@ggoodman Thanks, this is useful. |
This line is SSR:
It would fail if we try to build browser specific package that includes window or self variables. To make it work, we need to polyfill our nodejs env with browser polyfill like Unfortunately my project stuck in this state >.< |
I think I will try using JS parser like @babel/parser to parse the import keys. |
Adds a entryPoint field in the args of onLoad callback:
This is useful, here is an example, transform npm module to esm(solve the #864 problem):
1,This is entryPoints:
2, Collect the real entryPoints of npm module, it's very fast
The first build is to collect real entryPoints.
The collect result :
3, Start the final build, transform npm module to esm
The text was updated successfully, but these errors were encountered: