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.

Support generating a UMD bundle

See original GitHub issue

Choose one: feature request?

Right now, parcel is used for compiling code to be used for a frontend server. There’s no way to create a named library that you can use drop in a <script src='...'> tag and call via myLibrary.Foo(). Both rollup and webpack allow you to specify a config similar to

output: {
    file: 'dist/styled-components.js',
    format: 'umd',
    name: 'styled',
    exports: 'named',
}

It would be awesome if parcel supported something similar and wasn’t strictly for server/html code.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:26
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
devongovettcommented, May 1, 2018

Fixed by #453. Modules are now exposed to CommonJS and AMD automatically, and if you specify a --global <name> flag, as a global variable.

4reactions
zhaoyao91commented, Oct 14, 2021

@niieani - I’m not sure why this is not in V2, but here is my workaround:

window['MyGlobalName'] = myGlobalVar;

Need umd/iife format in v2 it is expected to bundle all dependencies into the final bundle expect the native node modules. I guess your workaround won’t handle the dependencies bundling problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Build Rollup UMD bundle for CommonJS - remarkablemark
To generate a UMD bundle with MyModuleName as the export name: npx rollup index.js --file dist/bundle.js --format umd --name 'MyModuleName'
Read more >
How to enable building UMD bundle again with Angular 13
I tried to find a way to enable building the UMD bundle again but was not ... There seems to be a way...
Read more >
Create and Publish a Universal JavaScript Module - Medium
Real example how to create a universal open-source javascript module that will work in both browser and NodeJS environments and publish to ...
Read more >
How to easily create JS libraries with bundled dependencies ...
experiments.outputModule = true - This is experimental and might result in empty umd output config.experiments.outputModule ...
Read more >
Standalone Builds - SurviveJS
To make the generated bundle work in different environments, bundlers support Universal Module Definition (UMD). The UMD wrapper allows the code to be ......
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