-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Today, babel’s caches (via babel-loader today) expires caches only if the options passed to it change, unfortunately if you upgrade a plugin without changing the configuration options and the file contents remains the same, the cache will not be evicted. This can lead to spurious caching problems if the associated plugins behavior has changed. To address this defect we now include (when available) the package.json#version of the babel plugins used in our own no-op babel plugin’s configuration. This new no-op plugin is then inserted at the end of the configuration in question.
- Loading branch information
1 parent
51cdcfa
commit 6dddcda
Showing
6 changed files
with
104 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export default function makePlugin(): any { | ||
// Dear future @rwjblue, | ||
// | ||
// This plugin exists as a sentinel plugin which has no behavior, but | ||
// provides a position in the babel configuration to include cache busting | ||
// meta-data about other plugins. Specifically their versions. | ||
// | ||
// Yours sincerely, | ||
// Contributor | ||
return {}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
import { maybeNodeModuleVersion } from '../src/portable'; | ||
import { readJSONSync } from 'fs-extra'; | ||
|
||
const EMBROIDER_CORE_VERSION = readJSONSync('../../package.json').version; | ||
const EMBROIDER_CORE_VERSION = readJSONSync(`${__dirname}/../package.json`).version; | ||
|
||
describe('maybeNodeModuleVersion', () => { | ||
test('it', () => { | ||
expect(maybeNodeModuleVersion('/dev/null')).toEqual(undefined); | ||
expect(maybeNodeModuleVersion('/does/not/exist')).toEqual(undefined); | ||
expect(() => maybeNodeModuleVersion('/dev/null')).toThrow(/Could not find package.json for '\/dev\/null'/); | ||
expect(() => maybeNodeModuleVersion('/does/not/exist')).toThrow( | ||
/Could not find package.json for '\/does\/not\/exist'/ | ||
); | ||
expect(maybeNodeModuleVersion(__dirname)).toEqual(EMBROIDER_CORE_VERSION); | ||
expect(maybeNodeModuleVersion(__filename)).toEqual(EMBROIDER_CORE_VERSION); | ||
}); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters