question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Request: provide clear example on creating non-trivial UMD bundles

See original GitHub issue

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 around tsdx 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:

import React, { useState, useEffect, useRef } from 'react';
import * as THREE from 'three';
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls';
import { TrackballControls } from 'three/examples/jsm/controls/TrackballControls';

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.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

2reactions
agilgur5commented, Nov 1, 2020

While I spent quite a bit of time responding, OP has not followed up… Closing as stale

0reactions
d-w-dcommented, May 18, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

provide clear example on creating non-trivial UMD bundles ...
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...
Read more >
CMSC 434 - Phase #2 - Spring 2022
If, for example, a team indicates that the salary should be an even split, ... team submit a request for a higher version...
Read more >
Bundling for the Web - Low Entropy
For content that is requested, a bundle might provide resources that a client does not know that it needs yet. Without bundling, a...
Read more >
How to Contribute - React
Open chrome://inspect and press “Inspect”. yarn flow runs the Flow typechecks. yarn build creates a build folder with all the packages. yarn build...
Read more >
rollup changelog
Pull Requests · #3722: Add import specifiers to bundle information (@lukastaegert) · #3724: Fix missing variables for UMD and IIFE builds (@ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found