JorgenVatle/meteor-vite

[ Meteor v3 ] - Add support to Meteor3?

Closed this issue ยท 9 comments

I was trying to make Vite, Meteor, and Angular work, and I found that it will not be possible in the 2.x version, due to an error with Node versions. (Maybe create an issue for making Meteor-vite with Angular?)

Currently, if you try using meteor-vite with Meteor 3 it gives this error:
Screenshot 2024-01-08 at 12 06 34

I tried publishing it just changing the package versions to be aware of Meteor 3 but it did not worked so well, this is my package.js:

Package.describe({
  name: 'grubba:vite-bundler-to-beta',
  version: '1.10.1-beta300.0',
  summary: 'Integrate the Vite.js bundler with Meteor',
  git: 'https://github.com/JorgenVatle/meteor-vite',
  documentation: 'README.md',
})

Package.registerBuildPlugin({
  name: 'vite',
  use: [
    'ecmascript@0.16.2 || 1.0.0 || 0.16.8-alpha300.19',
    'caching-compiler@1.2.2 || 2.0.0-beta300.0',
    'babel-compiler@7.9.0',
    'typescript@3.0.0 || 4.0.0 || 5.0.0 || 4.9.5-alpha300.19',
  ],
  sources: [
    'build.js',
    'workers.ts',
  ],
  npmDependencies: {
    execa: '6.1.0',
    'fs-extra': '10.1.0',
    'picocolors': '1.0.0',
  },
})

Npm.depends({
  'picocolors': '1.0.0',
});

Package.onUse(function(api) {
  api.versionsFrom(['1.8', '2.3', '2.12', '3.0-beta.0']);
  api.use([
      'fetch',
      'webapp',
      'typescript@3.0.0 || 4.0.0 || 5.0.0 || 4.9.5-alpha300.19',
      'isobuild:compiler-plugin@1.0.0',
  ]);
  api.use([
      'zodern:types@1.0.9',
  ], {
      weak: true,
  })
  api.addAssets(['loading/dev-server-splash.html'], 'server');
  api.mainModule('client.ts', 'client');
  api.mainModule('vite-server.ts', 'server')
})

Thanks for the hard work, @JorgenVatle!

Hey there. Sorry I couldn't get back to you earlier.

I still haven't quite familiarized myself with Meteor 3. I believe we do depend fairly heavily on fibers for the build process. Do you have any docs yet for the changes to Meteor's build system?

In the meantime, I'll do some tinkering and get back to you once I know more.

Turns out the migration to Meteor v3 wasn't all that bad. Could you give it a go with the meteor-v3 branch from #83?

There'll be an example app using Meteor v3.0-beta.0 and Vue. Got some quick tests done locally and it seems to run just fine with Meteor v3 now, at least for that one example app. ๐Ÿ˜…

Let me know how it goes. ๐Ÿคž

Do you have any docs yet for the changes to Meteor's build system?

I'm afraid we do not currently :/

I added to my to-do to test it again

Just had a deeper look at the changes introduced by Meteor v3. Seems like client bundle format has changed since V2. So there's still a little work left to be done before we have full compatibility with core Meteor packages.

I'll follow up with you once we have a stable patch ready to go. ๐Ÿ‘

Sure! Could you write your experience with updating a build plugin? That would also be great for other developers who might need to update their build plugins. I will be working on an in-depth how-to guide on updating to 3.0, and hearing people who already took the migration helps a lot in this effort.

I really didn't have to do a whole lot there. If I recall correctly, the only issue I ran into when running Meteor v3 was build plugins would not registering correctly when done asynchronously. Meteor-Vite would only register the plugin at the end of the Vite build process. Registering the build plugin asynchronously like we did previously would cause builds to fail and on occasion succeed.

Just registering the build plugin immediately and then optionally throwing in an "await" as a failsafe into the compiler's processFilesForTarget method seems to have resolved those issues. I think in most cases, the migration steps for plugin authors would be minimal, at least from what I've gathered so far.

@Grubba27 The v1.9.0 release of meteor-vite adds support for Meteor v3. I've only tested with core packages so far. If you run into any issues please do re-open the issue, or create a new one if that makes more sense. ๐Ÿ™Œ

@Grubba27 Just noticed that when publishing jorgenvatle:vite-bundler using the current stable version of Meteor, fibers would silently be added as a dependency. Only when publishing using a --release 3.0-beta.0 flag, the package would be published as expected.

You can pull down the Meteor-v3-built version of the package with jorgenvatle:vite-bundler@2.0.0-beta.0.