Skip to content

Commit

Permalink
Merge pull request meteor#12915 from meteor/docs/how-to-update-packag…
Browse files Browse the repository at this point in the history
…es-to-meteor-3

Docs/how to update packages to meteor 3
  • Loading branch information
Grubba27 authored Dec 7, 2023
2 parents d99ab7f + 64dcd99 commit 49ec190
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 0 deletions.
34 changes: 34 additions & 0 deletions guide/source/3.0-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,40 @@ The best way to follow the progress is by checking the "[What's left until an of

We plan to release the beta version by the end of Q4 2023. An official version will depend a lot on user feedback, but we aim to release it by the end of Q1 2024.


### How do I migrate my package to be compatible with Meteor 3.0?

For the packages that are client only
or that are do not using Meteor packages that will become async
or are already using `async` & `await` pattern.

The migration will look like this:

```js
// in you package.js
Package.onUse((api) => {
api.versionsFrom(['1.10', '2.3', '3.0-alpha.19']);
// ^^^^^^^ for testing your package with meteor 3.0

api.versionsFrom(['1.10', '2.3', '3.0']);
// ^^^^^^^ for meteor 3.0

```
Then you can publish your package and test it with Meteor 3.0.
If in your package you are using Meteor packages that will become async,
you will need to migrate your package to use `async` & `await` pattern.
For concrete examples you can check a few examples of packages that have been in the works
of migrating to Meteor 3.0:
- [`quave:migrations`](https://github.com/quavedev/meteor-migrations/pull/1)
- [`percolate:synced-cron`](https://github.com/percolatestudio/meteor-synced-cron/pull/149)
- [`react-meteor-accounts`](https://github.com/meteor/react-packages/commit/96313a1afcc41ef9a23c7496470b375e7d357793)
- [`mdg:seo`](https://github.com/meteor/galaxy-seo-package/commit/8a30b32688df40e62ce434475dd3ee931dedf2b3)
You can follow a more in depth guide on how to migrate your package to be compatible with Meteor 3.0 [here](/prepare-meteor-3.0#Changes-for-packages).
### When will React packages for Meteor be ready for version 3.0?
We consider React packages to be ready.
Expand Down
73 changes: 73 additions & 0 deletions guide/source/prepare-meteor-3.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,79 @@ Note that we're not using the if (loading) anymore. To see a practical project,
If you use `Tracker.autorun()`, for example, reading about the tracker with the [async callback function](https://blog.meteor.com/new-meteor-js-2-10-and-the-async-tracker-feature-ffdbe817c801) is also recommended.


## Changes for packages

### Meteor.isFibersDisabled

You can use the [`Meteor.isFibersDisabled`](https://github.com/meteor/meteor/blob/6ac474627a4d2536090484eb95e7c021370aaefe/packages/meteor/asl-helpers-client.js#L1-L8) property to check if the current Meteor version
is using Fibers or not. In all releases before Meteor 3.0 this property will be `falsy`(`undefined`).
In Meteor 3.0 this property will be return `true`.

Which means that you can have a code like this:

```js

if (Meteor.isFibersDisabled) {
// Meteor 3.0
} else {
// Meteor 2.x
}

```

### Changes for packages that are client-only

If your package is client-only, you don't need to worry about the async changes. You can update your package to be compatible with Meteor 3.0 by adding the following line to your `package.js`:

```js
Package.onUse((api) => {
api.versionsFrom(['1.10', '2.3', '3.0-alpha.19']);
// ^^^^^^^ for testing your package with meteor 3.0

api.versionsFrom(['1.10', '2.3', '3.0']);
// ^^^^^^^ for meteor 3.0
});
```

If you want an example of this change, you can take a look at this [commit](https://github.com/meteor/react-packages/commit/96313a1afcc41ef9a23c7496470b375e7d357793)
where it was made possible for a package to be used in Meteor 3.0.

This change makes sure that your package is still compatible with Meteor 2.x
and also with Meteor 3.0.


### Changes for packages that do not use Meteor packages that had breaking change

Similar to what happens with client-only packages,
if your package is not using Meteor packages that had breaking changes,
you can update your package to be compatible with Meteor 3.0
by adding the following line to your `package.js`:

```js
Package.onUse((api) => {
api.versionsFrom(['1.10', '2.3', '3.0-alpha.19']);
// ^^^^^^^ for testing your package with meteor 3.0

api.versionsFrom(['1.10', '2.3', '3.0']);
// ^^^^^^^ for meteor 3.0
});
```

For example, we have `mdg:seo` where we just needed to add the line above to make it
compatible with Meteor 3.0.
You can see the [commit](https://github.com/meteor/galaxy-seo-package/commit/8a30b32688df40e62ce434475dd3ee931dedf2b3).


### Changes for packages that are using Meteor API that will become async

In these packages, it will be necessary to refactor and migrate some of its APIs.
You can be ready for Meteor 3.0 by migrating its API to be async. You can run your tests
using Meteor 3.0 and ensure everything works as expected.

A good example can be seen here in this [PR](https://github.com/percolatestudio/meteor-synced-cron/pull/149), where we added support for any Meteor version
beyond v2.8 and also for Meteor 3.0.


-----------

We hope to make your transition easier with these instructions, references, and tools. You may face some challenges, but remember that you can progressively refactor it. For more detailed updates on Meteor 3.0, please check our [Fibers project board](https://github.com/orgs/meteor/projects/10) and the [Meteor 3.0 PR](https://github.com/meteor/meteor/pull/12359).

0 comments on commit 49ec190

Please sign in to comment.