Skip to content
This repository has been archived by the owner on Jun 29, 2021. It is now read-only.

Rebuild packages based on updated env variables #412

Open
jankapunkt opened this issue Nov 12, 2020 · 0 comments
Open

Rebuild packages based on updated env variables #412

jankapunkt opened this issue Nov 12, 2020 · 0 comments
Labels
Stage:In Discussion We are still discussing how to solve or implement it

Comments

@jankapunkt
Copy link

jankapunkt commented Nov 12, 2020

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:

  • create a package
  • add a console.log in package.js that outputs your process.env.
  • run your app
  • it outputs your current process.env
  • stop the app, start with different env variable
  • it wont output because the code is not reached, because the package is not rebuilt

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.

@filipenevola filipenevola added the Stage:In Discussion We are still discussing how to solve or implement it label Nov 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Stage:In Discussion We are still discussing how to solve or implement it
Projects
None yet
Development

No branches or pull requests

2 participants