-
Notifications
You must be signed in to change notification settings - Fork 508
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
Request: provide clear example on creating non-trivial UMD bundles #898
Comments
TSDX doesn't seem to have that many UMD users (it hasn't been part of the default Bundling is particularly more complex as it can involve I'll try to help with this with my limited time as I think this could be a good example / use-case and could potentially reveal some bugs. |
First, you might be able to get a library variant of Some unrelated comments:
|
Second, you've got some mismatches with your Rollup plugins that I'm not sure are intentional. Not sure if this branch is from a different debugging attempt that might explain it. You have two versions of You've currently overridden I'd try leaving all the plugins as is and just monkey-patching module.exports = {
rollup(config) {
if (config.output.format === 'umd') {
const origExternals = config.external
config.external = (id) => {
// bundle in ThreeJS plugins
if (id.startsWith('three/examples/')) {
return false;
}
return origExternal(id);
}
}
}
} Notice that the changes here are additive and are not replacing config. I'm not sure if you'll need to modify |
While I spent quite a bit of time responding, OP has not followed up... Closing as stale |
Sorry -- been busy and not able to get back to this. Thanks very much for your responses -- they were very helpful. In particular, I found that your module.exports = { ... } suggestion worked. |
Current Behavior
There is no guidance on how to include/exclude imported modules into a UMD bundle. I have spent a whole day playing around with
tsdx.config.js
and rollup plugins trying to make it work. I find both the rollup-plugin documentation and tsdx documentation lacking. By comparison, I have found it straightforward in the past to create UMDs with webpack.Desired Behavior
Here is my code, which includes a
tsdx.config.js
file. I want to be able to build a working UMD bundle when I run./_build_all
(a wrapper aroundtsdx build --format umd
). I also want to be able to control what gets bundled into the UMD. The 3rd party dependencies imported into my code are:For the UMD, I'd like the OrbitControls and TrackballControls bundled, but Three and React can be externalized.
Suggested Solution
Please show me how to configure my
tsdx.config.js
file to achieve my stated ends, and then consider including this as an example in your codebase to help others.Who does this impact? Who is this for?
Anyone who is trying to create a non-trivial UMD bundle will benefit from a clear example of a codebase with various dependencies where some need to be bundled, and some need to be excluded.
Describe alternatives you've considered
Abandon
tsdx/rollup
altogether and start again using webpack 5.The text was updated successfully, but these errors were encountered: