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
[transform-modules-umd] Better exported name for main module #5003
Comments
Could you please provide "Expected Behavior" and "Current Behavior" sections. |
Expected BehaviorThe Of course this is just an example because it should follow module resolution algorithm, such as the Current BehaviorThe |
We need a generic approach, which doesn't depend on a given directory structure. One possible solution could be to expose an option to be able to custom the final module name and use #4630 (.babelrc.js) to resolve the |
Hmm, I'm not sure it would be necessary, my use case is only for the entry point of the package. |
This can be easily done by using the const path = require("path");
module.exports = {
// Your normal config
presets: [
["@babel/preset-env", { modules: "umd" }],
],
overrides: [{
// Only apply these options to the entry point
include: path.resolve(__dirname, "src/index.js"),
moduleId: require("./package.json").name,
// If you prefer, you can specify the exact global identifier:
moduleId: "myLibrary",
}],
}; By doing so, Babel transforms don't have to understand node's resolution algorithm and it doesn't have to read non-babel options from |
@nicolo-ribaudo It was a long time ago so I don't remember my exact needs anymore but the whole point was to avoid specific configuration for each package. Anyway, I don't have this need anymore so I won't reopen. |
It would be nice if
babel-plugin-transform-modules-umd
would use the package name as exported name if the current file ismain
module of the package.I would allow me to add this transform into all my modules and have them being usable in browsers (via unpkg.com for instance) without special config :)
The text was updated successfully, but these errors were encountered: