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.

Consider building ESM for browser.

See original GitHub issue

TL;DR: For ES modules to work in a browser, import statements need the .js extension on them. https://github.com/Zoltu/typescript-transformer-append-js-extension/ is a a TypeScript transformer that will do that for you automatically during build.

For a detailed description of the problem see the Motivation section of https://github.com/Zoltu/typescript-transformer-append-js-extension/. For a solution, see the Usage section of the same repository.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
yysuncommented, Sep 24, 2019

Totally agreed, we should support future technologies.

In the apprun@latest release, the apprun.js is the UMD and ES5 build.

In the apprun@es6 release, the apprun.js is the UMD and ES2015 build. The apprun.esm.js is the ESM and ES2015 build, which is defined as pkg.module.

I hope someday I can make apprun@es6 as the default and latest.

0reactions
yysuncommented, Sep 25, 2019

If you really want unbundled modules, try this

<script type="module">
  import { app, Component } from 'https://unpkg.com/apprun@es6/esm/apprun?module';
</script>

unpkg.com can serve the modules dynamically by using the ?module parameter.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Life with ESM | CSS-Tricks
ESM, meaning ES Modules, meaning JavaScript Modules. Like, import and friends. Browsers support it these days. There is plenty of nuance, ...
Read more >
Use ESM build in modern browser (<script type="module ...
If we make a production, minified ESM build, that would support this feature. As a workaround, I think if you run tsdx build...
Read more >
Using ES modules in browsers with import-maps
In this post, we'll go through a few basic examples of how ES modules are used and then explore the possibility of using...
Read more >
All you need to know to move from CommonJS to ECMAScript ...
Because ESM implementation in Node.js and the browser conforms to the exact specification, we can share code between server and client runtime.
Read more >
How to Create a Hybrid NPM Module for ESM and CommonJS.
Build the source twice, once for ESM and once for CommonJS. We use Typescript as our transpiler, and author in ES6/ES-Next or Typescript....
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