modules/index.js should re-export tslib.es6.js instead of tslib.js
See original GitHub issueUnless I’m misunderstanding something, I’d expect modules/index.js
to re-export ../tslib.es6.js
instead of ../tslib.js
.
https://github.com/microsoft/tslib/blob/master/modules/index.js#L1
I’m basing my statement on the understanding that exports['.']['import']
should point to some “modern” code:
https://github.com/microsoft/tslib/blob/master/package.json#L29-L34
(The reason I’m opening this issue is that I’m facing some problem in combination with Vite which is based on ESM.)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:21 (6 by maintainers)
Top Results From Across the Web
SyntaxError: Unexpected token 'export' happens at tslib.es6.js ...
After renaming the tslib.es6.js to tslib.mjs the error is gone, but this is no solution. It should work after any yarn install.
Read more >ECMAScript modules | Node.js v19.3.0 Documentation
Instead, use import() to load an ES module from a CommonJS module. CommonJS Namespaces#. CommonJS modules consist of a module.exports object which can...
Read more >Best Practice Tips for Writing Your JS Modules
Author in ESM. You should write your modules in ESM format (or Typescript if you'd like) and have bundler output them to CJS...
Read more >Solved — Rxjs TypeError: Cannot destructure property '__ ...
es6.js instead of tslib.js ? Solution. The solution is simple. We can add a key alias in our Webpack ...
Read more >"Fossies" - the Fresh Open Source Software Archive
Member "src/node_modules/tslib/package.json" (26 Oct 1985, 1140 Bytes) of package ... 25 "module": "tslib.es6.js", 26 "jsnext:main": "tslib.es6.js", ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@DanielRosenwasser would love an eye on this.
From Vite resolver’s perspective,
module
is a non-standard condition inexports
, so it resolves to theimport
condition… which points to an ESM file that imports a UMD file (!!!). This does work in Node.js because Node allows ESM to import commonjs files… however for a native-ESM dev server like Vite, it assumes entries specified by theimport
condition to only contain valid ESM all the way through.On the other hand, why doesn’t the
import
condition simply point totslib.es6.js
? What is the point of having themodules/index.js
indirection?This can be fixed on Vite’s front by also checking the
module
condition inexports
field, but that is technically non-standard 😕https://github.com/firebase/firebase-js-sdk/pull/5532/files
This looks promising 🎉