-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
modules/index.js should re-export tslib.es6.js instead of tslib.js #143
Comments
@DanielRosenwasser would love an eye on this. From Vite resolver's perspective, On the other hand, why doesn't the This can be fixed on Vite's front by also checking the |
Any updates to this? I'm currently trying to understand whats wrong, but I have this error in my sveltekit project:
|
@wiesson Have you been able to figure this out yet? I'm getting the same error. Haven't been able to find anything that fixes it, include aliasing in |
Unfortunately not :/ I'm also not sure, if its tslib itself or another extension. Somehow deleting |
Have the same problem with sveltekit build in adapter-vercel phase. I hack-fixed this by running this script before executing npm run build:
|
This worked for me as well, although would love to see this fixed for real. |
I think this issue is related, isn't it? -> firebase/firebase-js-sdk#5499 @evil-su, could you share your findings so that the firebase team could fix it? :) |
https://github.com/firebase/firebase-js-sdk/pull/5532/files This looks promising 🎉 |
Switching to use |
I had to do this for import { readFile, writeFile } from 'fs/promises';
const importJson = async (path) => JSON.parse(await readFile(new URL(path, import.meta.url)));
const path = 'node_modules/@firebase/firestore/package.json';
const pkg = await importJson(path);
pkg.exports['.'].node = './dist/index.esm2017.js';
pkg.exports['./lite'].node = './dist/lite/index.browser.esm2017.js';
await writeFile(new URL(path, import.meta.url), JSON.stringify(pkg));
console.log('Successfully fixed imports.'); |
Can we at least just change re-export to
|
same issue here: #161 |
I've been getting the same issue with other packages when using sveltekit/vite - I've adapted your idea to fix it at the source by adding a default export to tslib. This seems to fix things for me. import fs from 'fs'
import path from 'path'
try {
const filePath = path.resolve('./node_modules/tslib/modules/index.js')
console.log('fixing tslib export', filePath)
let file = fs.readFileSync(filePath, 'utf8')
if (!file.includes('export default')) {
file += '\nexport default tslib;\n'
}
fs.writeFileSync(filePath, file)
} catch (err) {
console.error('error: fixing tslib export', err)
} It's not ideal so I'd love to see this fixed on tslib's end or from sveltekit/vite (not too sure which one is causing the issue at hand) |
NodeJS does not consider Rather than have The only alternative I can think of is to move the contents of |
Is this still an issue in Vite? I added a test locally using |
I've added a test for |
If it helps, the use case that led me here was trying to work with Material Web Components, in my case was just testing out @material/mwc-button and using ESM from the browser via import map. The dependency chain is pretty short:
|
Would import maps give you the ability to remap |
Yes, if hand rolling the import map as the 1st party, this would be doable. But similar to the Vite use case, the files to resolve (and the import map) are being determined programmatically, and so is entirely based on what the dependencies themselves define via their package.json. So this fix would be very useful to all ecosystem tools looking to operate against the spec in NodeJS. |
Can you provide a more detailed repro? |
Yeah, you can see this branch where I am trying to integrate MWC and hitting this issue. Following the ESM spec would be great here, so thanks in advance for taking a look. 🙏 |
I had a related issue. In my case, my site is deployed on Netlify and I have a transient dependency on tslib from "@azure/ai-form-recognizer": "^5.0.0",. After trying a bunch of different things that didn't work, I found this worked.
|
Unless 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.)
The text was updated successfully, but these errors were encountered: