-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
add invalidateOnEnvChange to resolver #8103
add invalidateOnEnvChange to resolver #8103
Conversation
an alternative is to change PathRequest.run to
|
Will check out why the test is failing |
Must be platform based. Passes on windows. Will update with an alternative. |
We don't really use unit tests for most things. For example like this one:
So there'd be a dummy resolver that uses |
Yes I had seen these tests. The approach I was using made it simpler to cover the paths taken, although it did require hacking the cache. From what I saw there is currently not a single intergration test for resolver plugins peforming any kind of invalidation. I am happy to do a single integration test for when there is a single resolver plugin that does resolve and invalidates some environment variables. This does not cover all paths. |
There are a number of those:
|
I realised I had discounted the default resolver plugin, in particular the NodeResolver, late last night. That I knew invalidated files from deriving from it for my alias plugin. So apologies for that. Which leads to the question. Shall incorporate my idea into NodeResolver ? An alias-file-path environment variable / alias key values ? |
I'm not aware of some standardized env-based alias in package.json. So no, there's no need to find an "artificial" usecase for this in the NodeResolver. |
Perhaps then you could tell me if Parcel supports my use case. I have a react app. I require 2:production builds, one with react-dom aliased for profiling. There are two different index.html sharing the same code. I can script the package.json alias but then this invalidates the other build as well as the development build. With an environment variable that will not change per entry ( I have 3 different entries ) then I believe I do not get this behaviour. Perhaps I have this wrong ? |
I should have said incorporate my idea into the default resolver plugin. |
Have you tried aliasing if (process.env.PROFILING) {
module.exports = require("react-dom/profiling");
} else {
module.exports = require("react-dom");
} |
This does not work
I cannot remember the error message exactly but I think it has to do with not providing a further alias - scheduler ? |
In the most simple case, that will just resolve to Anyway, would be great if you could do this:
|
With the version of react I am tied to ^17.0.2 - requiring react-dom/profiling.js will
From the link
So parcel does not support conditional aliases. Manually changing package.json / using a script and invalidating is the only solution. Anyway. I'll add the integration test shortly. |
…solver-invalidateOnEnvChange
…solver-invalidateOnEnvChange
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
@mischnic Please can this get merged. Thanks |
↪️ Pull Request
Fixes #8094
Added unit tests in PathRequest.test.js
To be able to test from the PathRequest I have pre-populated the build cache with a ParcelConfig that will be returned later. This allowed providing resolvers in the test.
Hopefully this is sufficient and that it is not necessary to create an integration test in https://github.com/parcel-bundler/parcel/blob/v2/packages/core/integration-tests/test/plugin.js
✔️ PR Todo