meteor / meteor-feature-requests

A tracker for Meteor issues that are requests for new functionality, not bugs.
Other
89 stars 3 forks source link

Rebuild packages based on updated env variables #412

Open jankapunkt opened 3 years ago

jankapunkt commented 3 years ago

Meteor release: 1.11.1

The expected behavior

When restarting with different env variables, packages should be rebuilt.

The current behaviour

When starting with differnt env variables, packages are not rebuilt, forcing me to run meteor reset which in turn also empties the database.

Reproduction:

Why

In order to create packages, which support both, static and dynamic import I am using environment variables as I think this is the only way to control this kind of configurability. For example:

Package.onUse(function (api) {
  api.use('ecmascript')

  if (!process.env.USE_DYNAMIC_IMPORTS) {
    api.addFiles([
      // ... all files are added here
    ]);
  } else {
    api.use('dynamic-import');
    api.mainModule('my-package.js');
  }
})

If a user accidentally forgets to set the variable and restarts the app with the correct environment variables then the package is not rebuilt and "keeps" the last configured state.

I am not sure if it's feasible to rebuild all packages based on a changed (hashed) env or if it's possible to implement something like api.getEnv('USE_DYNAMIC_IMPORTS') that keeps track of the env variable to rebuld only dependant packages, but I'd like to bring this to discussion.