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

fix($core): isProd is undefined in ready hook #2028

Closed
wants to merge 1 commit into from

Conversation

meteorlxy
Copy link
Member

Summary

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Docs
  • Build-related changes
  • Other, please describe:

If changing the UI of default theme, please provide the before/after screenshot:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

Other information:

Currently, we set isProd in app.dev() and app.build().

async build () {
this.isProd = true
this.buildProcess = new BuildProcess(this)
await this.buildProcess.process()
await this.buildProcess.render()
return this
}

As app.process() runs before app.dev() and app.build(), we cannot get isProd in app.process().

async function build (options) {
const app = createApp(options)
await app.process()
return app.build()
}

However, ready() hook is applied in app.process(), in which we may need isProd.

await this.pluginAPI.applyAsyncOption('ready')

So this PR fix this issue

@kefranabg
Copy link
Collaborator

Don't you think we should rely on the env variable? see this PR

@meteorlxy
Copy link
Member Author

@kefranabg

I didn't notice that PR.

But I think this PR is not related to the env vars, but the context API isProd, which should be available in ready() hook. They are similar but different 🤔 .

We can rely on env vars, but we still need to set isProd, otherwise we are introducing a breaking change.

@kefranabg
Copy link
Collaborator

I mean, instead of using an isProd property, check the NODE_ENV?

@meteorlxy
Copy link
Member Author

Yeah, that's why I said:

We can rely on env vars, but we still need to set isProd, otherwise we are introducing a breaking change.

ctx.isPord is listed in the documentation. So we should be careful if we really want to deperecate it.

@kefranabg
Copy link
Collaborator

Hmmm you're right, so maybe we could just do this.isProd = process.NODE_ENV === 'prod' in the createApp function?

meteorlxy added a commit that referenced this pull request Nov 27, 2019
@meteorlxy
Copy link
Member Author

close due to #1972

@meteorlxy meteorlxy closed this Nov 27, 2019
@meteorlxy meteorlxy deleted the fix/is-prod branch November 27, 2019 03:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants