Skip to content

Commit

Permalink
Cleanup config key invalidation feature for release (#9864)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattcompiles authored Jul 23, 2024
1 parent f58a5e8 commit ae96448
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
8 changes: 3 additions & 5 deletions packages/core/core/src/public/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,12 @@ export default class PublicConfig implements IConfig {
let packageKey = options?.packageKey;
if (packageKey != null) {
let pkg = await this.getConfigFrom(searchPath, ['package.json'], {
exclude: this.#options.featureFlags.configKeyInvalidation,
exclude: true,
});

if (pkg && pkg.contents[packageKey]) {
if (this.#options.featureFlags.configKeyInvalidation) {
// Invalidate only when the package key changes
this.invalidateOnConfigKeyChange(pkg.filePath, packageKey);
}
// Invalidate only when the package key changes
this.invalidateOnConfigKeyChange(pkg.filePath, packageKey);

return {
contents: pkg.contents[packageKey],
Expand Down
1 change: 0 additions & 1 deletion packages/core/core/test/test-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ export const DEFAULT_OPTIONS: ParcelOptions = {
},
featureFlags: {
exampleFeature: false,
configKeyInvalidation: false,
parcelV3: false,
},
};
Expand Down
1 change: 0 additions & 1 deletion packages/core/feature-flags/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export type FeatureFlags = _FeatureFlags;

export const DEFAULT_FEATURE_FLAGS: FeatureFlags = {
exampleFeature: false,
configKeyInvalidation: false,
parcelV3: false,
};

Expand Down
6 changes: 0 additions & 6 deletions packages/core/feature-flags/src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@
export type FeatureFlags = {|
// This feature flag mostly exists to test the feature flag system, and doesn't have any build/runtime effect
+exampleFeature: boolean,
/**
* Enables content hash based invalidation for config keys used in plugins.
* This allows Assets not to be invalidated when using
* `config.getConfigFrom(..., {packageKey: '...'})` and the value itself hasn't changed.
*/
+configKeyInvalidation: boolean,
/**
* Rust backed requests
*/
Expand Down
3 changes: 0 additions & 3 deletions packages/core/integration-tests/test/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -1318,7 +1318,6 @@ describe('cache', function () {
let b = await testCache({
featureFlags: {
exampleFeature: false,
configKeyInvalidation: true,
parcelV3: false,
},
async setup() {
Expand Down Expand Up @@ -1379,7 +1378,6 @@ describe('cache', function () {
let b = await testCache({
featureFlags: {
exampleFeature: false,
configKeyInvalidation: true,
parcelV3: false,
},
async setup() {
Expand Down Expand Up @@ -1440,7 +1438,6 @@ describe('cache', function () {
let b = await testCache({
featureFlags: {
exampleFeature: false,
configKeyInvalidation: true,
parcelV3: false,
},
async setup() {
Expand Down
23 changes: 18 additions & 5 deletions packages/core/integration-tests/test/incremental-bundling.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
inputFS,
overlayFS,
run,
fsFixture,
} from '@parcel/test-utils';
import assert from 'assert';
import path from 'path';
Expand Down Expand Up @@ -712,21 +713,33 @@ console.log('index.js');`,

it('changing bundler options', async () => {
let subscription;
let fixture = path.join(__dirname, '/integration/incremental-bundling');
try {
let b = bundler(path.join(fixture, 'index.js'), {
await fsFixture(overlayFS, __dirname)`
index.js:
export default 1;
package.json:
{
"@parcel/bundler-default": {
"http": 2
}
}
yarn.lock:`;

let b = bundler(path.join(__dirname, 'index.js'), {
inputFS: overlayFS,
shouldDisableCache: false,
shouldBundleIncrementally: true,
});

await overlayFS.mkdirp(fixture);
await overlayFS.mkdirp(__dirname);
subscription = await b.watch();

let event = await getNextBuildSuccess(b);
assertTimesBundled(defaultBundlerSpy.callCount, 1);

let pkgFile = path.join(fixture, 'package.json');
let pkgFile = path.join(__dirname, 'package.json');
let pkg = JSON.parse(await overlayFS.readFile(pkgFile));
await overlayFS.writeFile(
pkgFile,
Expand All @@ -741,7 +754,7 @@ console.log('index.js');`,
event = await getNextBuildSuccess(b);

// should contain all the assets
assertChangedAssets(event.changedAssets.size, 3);
assertChangedAssets(event.changedAssets.size, 2);
assertTimesBundled(defaultBundlerSpy.callCount, 2);
} finally {
if (subscription) {
Expand Down

0 comments on commit ae96448

Please sign in to comment.