Feature: Support package.json exports fields #11727
Replies: 26 comments 10 replies
-
I don't follow, are you getting an error when you are trying to import from Swipper 7? For example: import Swiper from 'swiper/swiper-bundle.esm.js'; or import Swiper from 'swiper'; |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Shouldn't it be? import Swiper, { SwiperSlide } from 'swiper/react'; |
Beta Was this translation helpful? Give feedback.
-
No, that comes directly from their docs and the react component inherits swiper core. At least thats my understanding. |
Beta Was this translation helpful? Give feedback.
-
I still don't understand what the problem here is. |
Beta Was this translation helpful? Give feedback.
-
It can’t find the module, app breaks. I have to use version 6 for it to work. It looks like meteor can’t use ESM packages. I’ll setup a meteor app only loading that component. |
Beta Was this translation helpful? Give feedback.
-
here is the repo with version 7 Server
Client Side
|
Beta Was this translation helpful? Give feedback.
-
OK, I see now! Yeah, that is indeed not working. Right now workaround would be to import from the files directly like this: import 'swiper/swiper.min.css'; But that is only a stop gap solution. @zodern @renanccastro @filipenevola "exports": {
".": "./swiper.esm.js",
"./core": "./swiper.esm.js",
"./bundle": "./swiper-bundle.esm.js",
"./css": "./swiper.min.css",
"./css/bundle": "./swiper-bundle.min.css",
"./css/a11y": "./modules/a11y/a11y.min.css",
"./css/autoplay": "./modules/autoplay/autoplay.min.css",
... |
Beta Was this translation helpful? Give feedback.
-
Even TypeScript barely just added support for recognizing package.json The only solution right now is to import the files directly until Meteor adds support for it as well. Keep one thing in mind about this workaround though: importing files directly will work in Meteor, but will fail in Node apps, or in Webpack which also follows the latest Node ESM spec. If you have some code in package A, for example, and it imports files directly from some package B, this will work in Meteor, but it will throw an error in Node or Webpack apps. |
Beta Was this translation helpful? Give feedback.
-
This is a duplicate of #10906 |
Beta Was this translation helpful? Give feedback.
-
Some notes from me digging around this: |
Beta Was this translation helpful? Give feedback.
-
Is this something that only needs an upstream (upcoming) update of TypeScript? |
Beta Was this translation helpful? Give feedback.
-
I don't think that will be it. I think the problem here for me is to pin the issue down. Meteor already supports what is commonly known as JavaScript modules. What we are talking about here is a new feature which allows developers to specify their exports under export param in |
Beta Was this translation helpful? Give feedback.
-
Here is the relevant docs from Node.js: https://nodejs.org/api/packages.html#packages_exports |
Beta Was this translation helpful? Give feedback.
-
I just ran into this issue, specifically the desire for export conditions (see this Node documentation). I'm using the So when implementing support for |
Beta Was this translation helpful? Give feedback.
-
Found a related issue in Reify with comment from @benjamn : benjamn/reify#329 |
Beta Was this translation helpful? Give feedback.
-
The
Node supports it, but code in Meteor that passes through Meteor's build system
No matter what, if we're bundling code for the client, then we need to support Node ESM format to be compatible with packages that are moving forward to Node ESM. Package authors should avoid the |
Beta Was this translation helpful? Give feedback.
-
In my opinion, this should not be a GitHub discussion, but an issue. This is fairly critical, not a discussion topic for debate, and as more packages become Node ESM-flavored on npm, Meteor is going to lose compatibility with those packages. At some point, the lack of support will be considered a bug, and it should be acted on in order to keep Meteor relevant. |
Beta Was this translation helpful? Give feedback.
-
Hi, you might want to take a look at "file-type", this is an example of a package that do not work with Meteor: https://www.npmjs.com/package/file-type However to be completely fair, many packages may have weird exports and are not supported by many bundlers. For instance, @apollo/client doesn't load correctly in Next.js, and other Webpack 5-based bundlers, when it's a dependency of another ESM modules (like a package that exposes some hooks based on Apollo), because it doesn't have exports map. |
Beta Was this translation helpful? Give feedback.
-
This just landed on Reify issue tracker, not sure about it, but might be useful: benjamn/reify#365 |
Beta Was this translation helpful? Give feedback.
-
Hi, I've stumbled upon the ESM issue here: https://github.com/orgs/mdx-js/discussions/2088 I was wondering what the progress/stance is on whether Meteor is going to be supporting ESM packages, as I don't see any conclusion on what we should be doing moving forward. Thanks. |
Beta Was this translation helpful? Give feedback.
-
As commented by @StorytellerCZ and requested by @zodern, I've updated the discussion name from: |
Beta Was this translation helpful? Give feedback.
-
Apologies if this is a silly question or the wrong place to ask, but should it be possible to create a Meteor app as an ESM? I've set up my project as an ESM, but this causes
Is there any way to avoid this? |
Beta Was this translation helpful? Give feedback.
-
@Grubba27, @StorytellerCZ, Should this issue be considered in v3.0? Newer packages have started using it. Thanks! |
Beta Was this translation helpful? Give feedback.
-
I think I'm encountering this issue with Angular, see Urigo/angular-meteor#1988 |
Beta Was this translation helpful? Give feedback.
-
Babel v8 is going to be ESM only: https://babeljs.io/docs/v8-migration |
Beta Was this translation helpful? Give feedback.
-
Right now I'm stuck with version 6 of swiper and would like to upgrade to 7 but it requires ESM support.
Is there a way for us to use ESM packages in meteor?
SwiperJS
Beta Was this translation helpful? Give feedback.
All reactions