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.

Generate esm output for xterm.js

See original GitHub issue

Hello!

Currently, we are using Rollup to handle our bundling. We recently upgraded from 3.14.5 to 4.10.0, and got the error of:

Screen Shot 2019-10-18 at 3 32 18 PM

I’ll admit I didn’t verify if it is correctly giving the name export since node_modules/xterm/lib/xterm.js is minified, or this honestly may be an issue with Rollup. But if I’m not mistaken, generating an esm build would also allow for better tree shaking, which according to bundlephobia currently is not supported.

Thanks! I’m open to opening this PR myself if needed, as I think it’s a small change in the webpack config 😄

Looking forward to the response!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
Tyriarcommented, Oct 23, 2019

Let’s close for now since we’re blocked on it, but feel free to open a new issue or comment on this one when https://github.com/webpack/webpack/issues/2933 gets resolved. I think even if TS supported it as a target that wouldn’t be enough since we use custom path mappings.

2reactions
torch2424commented, Oct 23, 2019

@Tyriar

It doesn’t look like module is supported/documented by npm? https://docs.npmjs.com/files/package.json

Ah yes, I don’t think npm highlights it, since they focus on the “node” use case? But it is a common pattern. For instance, looking at comlink, their npm package has the module field and bundlers will respect it

@mofux

I’ve run some quick tests to see if we can support a module build relatively easy.

Ah, thank you very very much for looking into this! 😄

Unfortunately typescript itself does not support translating our absolute imports into relative ones (and there is not much hope that they will do soon: microsoft/TypeScript#33118 (comment)). There are hacks to get this working, but I’d rather not rely on them as they all seem very fragile. The other option would be to use webpack to create the esm build for us, but unfortunately webpack does not support modules as a library target yet. There is hope that the not yet release webpack v5 can bring support for it: webpack/webpack#2933

Ah that’s quite unfortunate, didn’t know that Typescript and Webpack had troubles with this. Definitely not a smalled fix like I had originally though. Thanks for all the context and looking into this 👍

I’d say let’s revise this topic in a few month time and see if support in either webpack or typescript has been added.

Totally, sounds like a good plan to me 😄

@Tyriar @mofux

You think it’d be a good idea to close this for now? Or keep it open for the future? I’m open to either 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to build and use xterm.js locally? - Stack Overflow
To start using xterm.js on your browser, add the xterm.js and xterm.css to the head of your html page. Then create a onto...
Read more >
Encoding - Xterm.js
Output. Terminal.onData. contains real string data with any valid Unicode codepoint, thus the payload should be treated as UTF-16/UCS-2.
Read more >
xterm-for-react - npm Package Health Analysis - Snyk
The main component to this library is 'XTerm'. This will create a div and use it to open a XTerm.js terminal. The base...
Read more >
[pve-devel] [PATCH xtermjs 1/3] upgrade xterm.js to version ...
adapt version of xterm.js also download and unpack xterm-addon-fit ... __esModule) return value;\n \t\tvar ns = Object.create(null);\n ...
Read more >
sourcelair/xterm.js - Gitter
vue.esm.js?efeb:1897 TypeError: term.on is not a function ... Hey Guys, I just create a xterm playback tool with audio support based on xterm.js....
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