Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getPolyfillString emits invalid environment warning when used as library #1145

Open
cdaringe opened this issue Dec 13, 2021 · 0 comments
Open
Labels
library Relates to an Origami library

Comments

@cdaringe
Copy link
Contributor

cdaringe commented Dec 13, 2021

What

getPolyfillString() emits an ENV warning in the emitted javascript, against expectation.

I call getPolyfillString from library code, not via a service, however, getPolyfillString assumes it's being run as a service, and reads the ENV vs its passed params.

I cannot mutate NODE_ENV to "production" in my library, as other references are coupled to NODE_ENV as well. Global mutations are also discouraged as general programming practice, and my library is permissible to use in development.

Details

describe what the expected behaviour is, and what is actually happening

expected: The emitted code emits no environment warning in the emitted javascript
actual: The emitted code emits an environment warning in the emitted javascript

getPolyfillString can be a pure function, but has implicit coupling to being attached to the pf.io service

add steps on how to reproduce it

Call getPolyfillString() with a non-production NODE_ENV, observe JS output

explain what alternatives you have explored / considered

Permit appVersionText to be configurable here.

example:

const appVersionText = options.appVersionText 
  ? options.appVersionText 
  : "Polyfill service " +
  (process.env.NODE_ENV === "production"
    ? "v" + appVersion
    : "DEVELOPMENT MODE - for live use set NODE_ENV to 'production'")
@github-actions github-actions bot added the library Relates to an Origami library label Dec 13, 2021
@robertboulton robertboulton removed this from Backlog in Origami ✨ Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
library Relates to an Origami library
Projects
None yet
Development

No branches or pull requests

1 participant