Skip to content

Commit 0e2d56f

Browse files
committed
Add cache key based on the project's addon versions
1 parent 2fe80c3 commit 0e2d56f

3 files changed

Lines changed: 59 additions & 95 deletions

File tree

‎packages/macros/src/ember-addon-main.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ export = {
6868
let babelPlugins = (babelOptions.plugins = babelOptions.plugins || []);
6969
if (!babelPlugins.some(isEmbroiderMacrosPlugin)) {
7070
let appInstance = this._findHost();
71-
let source = appOrAddonInstance.root || appOrAddonInstance.project.root;
72-
babelPlugins.unshift(...MacrosConfig.for(appInstance).babelPluginConfig(source));
71+
babelPlugins.unshift(...MacrosConfig.for(appInstance).babelPluginConfig(appOrAddonInstance));
7372
}
7473
},
7574

‎packages/macros/src/macros-config.ts‎

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ type GlobalSharedState = WeakMap<
4141
// share the GlobalSharedState beneath.
4242
let localSharedState: WeakMap<any, MacrosConfig> = new WeakMap();
4343

44+
// creates a string representing all addons and their versions
45+
// (foo@1.0.0|bar@2.0.0) to use as a cachekey
46+
function gatherAddonCacheKey(item: any, memo = new Set()) {
47+
item.addons.forEach((addon: any) => {
48+
let key = `${addon.pkg.name}@${addon.pkg.version}`;
49+
memo.add(key);
50+
gatherAddonCacheKey(addon, memo);
51+
});
52+
53+
return [...memo].join('|');
54+
}
55+
4456
export default class MacrosConfig {
4557
static for(key: any): MacrosConfig {
4658
let found = localSharedState.get(key);
@@ -258,8 +270,9 @@ export default class MacrosConfig {
258270
// normal node_modules resolution can find their dependencies. In other words,
259271
// owningPackageRoot is needed when you use this inside classic ember-cli, and
260272
// it's not appropriate inside embroider.
261-
babelPluginConfig(owningPackageRoot?: string): PluginItem[] {
273+
babelPluginConfig(appOrAddonInstance?: any): PluginItem[] {
262274
let self = this;
275+
let owningPackageRoot = appOrAddonInstance ? appOrAddonInstance.root || appOrAddonInstance.project.root;
263276
let opts: State['opts'] = {
264277
// this is deliberately lazy because we want to allow everyone to finish
265278
// setting config before we generate the userConfigs
@@ -300,7 +313,13 @@ export default class MacrosConfig {
300313
// the old evaluated state being used which might be invalid. This cache busting plugin keeps track of a
301314
// hash representing the lock file of the app and if it ever changes forces babel to rerun its plugins.
302315
// more information in issue #906
303-
let cacheKey = crypto.createHash('sha256').update(lockFileBuffer).digest('hex');
316+
let hash = crypto.createHash('sha256');
317+
hash = hash.update(lockFileBuffer);
318+
if (appOrAddonInstance) {
319+
hash = hash.update(gatherAddonCacheKey(appOrAddonInstance.project));
320+
}
321+
let cacheKey = hash.digest('hex');
322+
304323
return [
305324
[join(__dirname, 'babel', 'macros-babel-plugin.js'), opts],
306325
[

‎yarn.lock‎

Lines changed: 37 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -5656,24 +5656,16 @@ browserify-zlib@^0.2.0:
56565656
dependencies:
56575657
pako "~1.0.5"
56585658

5659-
browserslist@^3.2.6:
5660-
version "3.2.8"
5661-
resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-3.2.8.tgz#b0005361d6471f0f5952797a76fc985f1f978fc6"
5662-
integrity sha512-WHVocJYavUwVgVViC0ORikPHQquXwVh939TaelZ4WDqpWgTX/FsGhl/+P4qBUAGcRvtOgDgC+xftNWWp2RUTAQ==
5663-
dependencies:
5664-
caniuse-lite "^1.0.30000844"
5665-
electron-to-chromium "^1.3.47"
5666-
5667-
browserslist@^4.0.0, browserslist@^4.14.5, browserslist@^4.16.6:
5668-
version "4.17.0"
5669-
resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.17.0.tgz#1fcd81ec75b41d6d4994fb0831b92ac18c01649c"
5670-
integrity sha512-g2BJ2a0nEYvEFQC208q8mVAhfNwpZ5Mu8BwgtCdZKO3qx98HChmeg448fPdUzld8aFmfLgVh7yymqV+q1lJZ5g==
5671-
dependencies:
5672-
caniuse-lite "^1.0.30001254"
5673-
colorette "^1.3.0"
5674-
electron-to-chromium "^1.3.830"
5659+
browserslist@^3.2.6, browserslist@^4.0.0, browserslist@^4.14.0, browserslist@^4.14.5, browserslist@^4.16.6:
5660+
version "4.17.2"
5661+
resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.17.2.tgz#aa15dbd2fab399a399fe4df601bb09363c5458a6"
5662+
integrity sha512-jSDZyqJmkKMEMi7SZAgX5UltFdR5NAO43vY0AwTpu4X3sGH7GLLQ83KiUomgrnvZRCeW0yPPnKqnxPqQOER9zQ==
5663+
dependencies:
5664+
caniuse-lite "^1.0.30001261"
5665+
electron-to-chromium "^1.3.854"
56755666
escalade "^3.1.1"
5676-
node-releases "^1.1.75"
5667+
nanocolors "^0.2.12"
5668+
node-releases "^1.1.76"
56775669

56785670
bser@2.1.1:
56795671
version "2.1.1"
@@ -5909,16 +5901,11 @@ caniuse-lite@^1.0.0:
59095901
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001236.tgz#0a80de4cdf62e1770bb46a30d884fc8d633e3958"
59105902
integrity sha512-o0PRQSrSCGJKCPZcgMzl5fUaj5xHe8qA2m4QRvnyY4e1lITqoNkr7q/Oh1NcpGSy0Th97UZ35yoKcINPoq7YOQ==
59115903

5912-
caniuse-lite@^1.0.30000844:
5904+
caniuse-lite@^1.0.30001261:
59135905
version "1.0.30001263"
59145906
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001263.tgz#7ce7a6fb482a137585cbc908aaf38e90c53a16a4"
59155907
integrity sha512-doiV5dft6yzWO1WwU19kt8Qz8R0/8DgEziz6/9n2FxUasteZNwNNYSmJO3GLBH8lCVE73AB1RPDPAeYbcO5Cvw==
59165908

5917-
caniuse-lite@^1.0.30001254:
5918-
version "1.0.30001257"
5919-
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001257.tgz#150aaf649a48bee531104cfeda57f92ce587f6e5"
5920-
integrity sha512-JN49KplOgHSXpIsVSF+LUyhD8PUp6xPpAXeRrrcBh4KBeP7W864jHn6RvzJgDlrReyeVjMFJL3PLpPvKIxlIHA==
5921-
59225909
capture-exit@^2.0.0:
59235910
version "2.0.0"
59245911
resolved "https://registry.yarnpkg.com/capture-exit/-/capture-exit-2.0.0.tgz#fb953bfaebeb781f62898239dabb426d08a509a4"
@@ -6283,11 +6270,6 @@ colorette@^1.2.2:
62836270
resolved "https://registry.yarnpkg.com/colorette/-/colorette-1.2.2.tgz#cbcc79d5e99caea2dbf10eb3a26fd8b3e6acfa94"
62846271
integrity sha512-MKGMzyfeuutC/ZJ1cba9NqcNpfeqMUcYmyF1ZFY6/Cn7CNSAKx6a+s48sqLqyAiZuaP2TcqMhoo+dlwFnVxT9w==
62856272

6286-
colorette@^1.3.0:
6287-
version "1.3.0"
6288-
resolved "https://registry.yarnpkg.com/colorette/-/colorette-1.3.0.tgz#ff45d2f0edb244069d3b772adeb04fed38d0a0af"
6289-
integrity sha512-ecORCqbSFP7Wm8Y6lyqMJjexBQqXSF7SSeaTyGGphogUjBlFP9m9o08wy86HL2uB7fMTxtOUzLMk7ogKcxMg1w==
6290-
62916273
colors@1.0.3:
62926274
version "1.0.3"
62936275
resolved "https://registry.yarnpkg.com/colors/-/colors-1.0.3.tgz#0433f44d809680fdeb60ed260f1b0c262e82a40b"
@@ -6317,10 +6299,10 @@ commander@2.8.x:
63176299
dependencies:
63186300
graceful-readlink ">= 1.0.0"
63196301

6320-
commander@7.1.0:
6321-
version "7.1.0"
6322-
resolved "https://registry.yarnpkg.com/commander/-/commander-7.1.0.tgz#f2eaecf131f10e36e07d894698226e36ae0eb5ff"
6323-
integrity sha512-pRxBna3MJe6HKnBGsDyMv8ETbptw3axEdYHoqNh7gu5oDcew8fs0xnivZGm06Ogk8zGAJ9VX+OPEr2GXEQK4dg==
6302+
commander@7.2.0:
6303+
version "7.2.0"
6304+
resolved "https://registry.yarnpkg.com/commander/-/commander-7.2.0.tgz#a36cb57d0b501ce108e4d20559a150a391d97ab7"
6305+
integrity sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==
63246306

63256307
commander@^2.15.1, commander@^2.19.0, commander@^2.20.0, commander@^2.6.0:
63266308
version "2.20.3"
@@ -7136,16 +7118,11 @@ ee-first@1.1.1:
71367118
resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d"
71377119
integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=
71387120

7139-
electron-to-chromium@^1.3.47:
7121+
electron-to-chromium@^1.3.854:
71407122
version "1.3.856"
71417123
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.856.tgz#75dee0eef9702bffabbf4c1293c989cd3cacb7ba"
71427124
integrity sha512-lSezYIe1/p5qkEswAfaQUseOBiwGwuCvRl/MKzOEVe++DcmQ92+43dznDl4rFJ4Zpu+kevhwyIf7KjJevyDA/A==
71437125

7144-
electron-to-chromium@^1.3.830:
7145-
version "1.3.840"
7146-
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.840.tgz#3f2a1df97015d9b1db5d86a4c6bd4cdb920adcbb"
7147-
integrity sha512-yRoUmTLDJnkIJx23xLY7GbSvnmDCq++NSuxHDQ0jiyDJ9YZBUGJcrdUqm+ZwZFzMbCciVzfem2N2AWiHJcWlbw==
7148-
71497126
elliptic@^6.5.3:
71507127
version "6.5.4"
71517128
resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.4.tgz#da37cebd31e79a1367e941b592ed1fbebd58abbb"
@@ -9938,21 +9915,7 @@ fastboot-transform@^0.1.0, fastboot-transform@^0.1.3:
99389915
broccoli-stew "^1.5.0"
99399916
convert-source-map "^1.5.1"
99409917

9941-
fastboot@^2.0.0, fastboot@^2.0.1:
9942-
version "2.0.3"
9943-
resolved "https://registry.yarnpkg.com/fastboot/-/fastboot-2.0.3.tgz#0b712e6c590f1b463dc5b12138893bcbbafa2459"
9944-
integrity sha512-NNH/o+XhITAQUnW2CC9IDXlcnI74W2BONjtRSRmc01N3uJl/7pcvX9iWTUWu2PYQbQZUBu8HzVFt7GmQ9qw9JQ==
9945-
dependencies:
9946-
chalk "^2.0.1"
9947-
cookie "^0.4.0"
9948-
debug "^4.1.0"
9949-
najax "^1.0.3"
9950-
resolve "^1.8.1"
9951-
rsvp "^4.8.0"
9952-
simple-dom "^1.4.0"
9953-
source-map-support "^0.5.0"
9954-
9955-
fastboot@^3.1.0:
9918+
fastboot@^2.0.0, fastboot@^2.0.1, fastboot@^3.1.0:
99569919
version "3.1.2"
99579920
resolved "https://registry.yarnpkg.com/fastboot/-/fastboot-3.1.2.tgz#c10a97be3a61fbbf9e4bd8abc43373e8739d1787"
99589921
integrity sha512-yvhJfIRd4wWWACk+qjJxQI+WBIQ+pyQyp0/fxrQyA/cYJgZAXOHb+22zXJbJXaPku3fHS+gBl7crwovIkl8bhQ==
@@ -12442,11 +12405,6 @@ jest@^24.9.0:
1244212405
import-local "^2.0.0"
1244312406
jest-cli "^24.9.0"
1244412407

12445-
jquery-deferred@^0.3.0:
12446-
version "0.3.1"
12447-
resolved "https://registry.yarnpkg.com/jquery-deferred/-/jquery-deferred-0.3.1.tgz#596eca1caaff54f61b110962b23cafea74c35355"
12448-
integrity sha1-WW7KHKr/VPYbEQlisjyv6nTDU1U=
12449-
1245012408
jquery@^3.4.1, jquery@^3.5.0, jquery@^3.5.1:
1245112409
version "3.6.0"
1245212410
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.6.0.tgz#c72a09f15c1bdce142f49dbf1170bdf8adac2470"
@@ -13782,20 +13740,16 @@ mz@^2.4.0:
1378213740
object-assign "^4.0.1"
1378313741
thenify-all "^1.0.0"
1378413742

13785-
najax@^1.0.3:
13786-
version "1.0.7"
13787-
resolved "https://registry.yarnpkg.com/najax/-/najax-1.0.7.tgz#706dce52d4b738dce01aee97f392ccdb79d51eef"
13788-
integrity sha512-JqBMguf2plv1IDqhOE6eebnTivjS/ej0C/Sw831jVc+dRQIMK37oyktdQCGAQtwpl5DikOWI2xGfIlBPSSLgXg==
13789-
dependencies:
13790-
jquery-deferred "^0.3.0"
13791-
lodash "^4.17.21"
13792-
qs "^6.2.0"
13793-
1379413743
nan@^2.12.1:
1379513744
version "2.14.2"
1379613745
resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.2.tgz#f5376400695168f4cc694ac9393d0c9585eeea19"
1379713746
integrity sha512-M2ufzIiINKCuDfBSAUr1vWQ+vuVcA9kqx8JJUsbQi6yf1uGRyb7HfpdfUr5qLXf3B/t8dPvcjhKMmlfnP47EzQ==
1379813747

13748+
nanocolors@^0.2.12:
13749+
version "0.2.12"
13750+
resolved "https://registry.yarnpkg.com/nanocolors/-/nanocolors-0.2.12.tgz#4d05932e70116078673ea4cc6699a1c56cc77777"
13751+
integrity sha512-SFNdALvzW+rVlzqexid6epYdt8H9Zol7xDoQarioEFcFN0JHo4CYNztAxmtfgGTVRCmFlEOqqhBpoFGKqSAMug==
13752+
1379913753
nanoid@^3.1.23:
1380013754
version "3.1.23"
1380113755
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.1.23.tgz#f744086ce7c2bc47ee0a8472574d5c78e4183a81"
@@ -13918,15 +13872,15 @@ node-notifier@^9.0.1:
1391813872
uuid "^8.3.0"
1391913873
which "^2.0.2"
1392013874

13921-
node-releases@^1.1.75:
13922-
version "1.1.75"
13923-
resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.75.tgz#6dd8c876b9897a1b8e5a02de26afa79bb54ebbfe"
13924-
integrity sha512-Qe5OUajvqrqDSy6wrWFmMwfJ0jVgwiw4T3KqmbTcZ62qW0gQkheXYhcFM1+lOVcGUoRxcEcfyvFMAnDgaF1VWw==
13875+
node-releases@^1.1.76:
13876+
version "1.1.76"
13877+
resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.76.tgz#df245b062b0cafbd5282ab6792f7dccc2d97f36e"
13878+
integrity sha512-9/IECtNr8dXNmPWmFXepT0/7o5eolGesHUa3mtr0KlgnCvnZxwh2qensKL42JJY2vQKC3nIBXetFAqR+PW1CmA==
1392513879

13926-
node-watch@0.7.1:
13927-
version "0.7.1"
13928-
resolved "https://registry.yarnpkg.com/node-watch/-/node-watch-0.7.1.tgz#0caaa6a6833b0d533487f953c52a6c787769ba7c"
13929-
integrity sha512-UWblPYuZYrkCQCW5PxAwYSxaELNBLUckrTBBk8xr1/bUgyOkYYTsUcV4e3ytcazFEOyiRyiUrsG37pu6I0I05g==
13880+
node-watch@0.7.2:
13881+
version "0.7.2"
13882+
resolved "https://registry.yarnpkg.com/node-watch/-/node-watch-0.7.2.tgz#545f057da8500487eb8287adcb4cb5a7338d7e21"
13883+
integrity sha512-g53VjSARRv1JdST0LZRIg8RiuLr1TaBbVPsVvxh0/0Ymvi0xYUjDuoqQQAWtHJQUXhiShowPT/aXKNeHBcyQsw==
1393013884

1393113885
nopt@^3.0.6:
1393213886
version "3.0.6"
@@ -15006,7 +14960,7 @@ qs@6.7.0:
1500614960
resolved "https://registry.yarnpkg.com/qs/-/qs-6.7.0.tgz#41dc1a015e3d581f1621776be31afb2876a9b1bc"
1500714961
integrity sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==
1500814962

15009-
qs@^6.2.0, qs@^6.4.0, qs@^6.9.4:
14963+
qs@^6.4.0, qs@^6.9.4:
1501014964
version "6.10.1"
1501114965
resolved "https://registry.yarnpkg.com/qs/-/qs-6.10.1.tgz#4931482fa8d647a5aab799c5271d2133b981fb6a"
1501214966
integrity sha512-M528Hph6wsSVOBiYUnGf+K/7w0hNshs/duGsNXPUCLH5XAqjEtiPGwNONLV0tBH8NoGb0mvD5JubnUTrujKDTg==
@@ -15076,13 +15030,13 @@ qunit-dom@^1.6.0:
1507615030
ember-cli-babel "^7.23.0"
1507715031
ember-cli-version-checker "^5.1.1"
1507815032

15079-
qunit@^2.16.0:
15080-
version "2.17.1"
15081-
resolved "https://registry.yarnpkg.com/qunit/-/qunit-2.17.1.tgz#1969efe4c9b776b4b8cd4fc2fb9634e8f762e177"
15082-
integrity sha512-Gx1tpSfYbjRe4TRKCVBLlnCaVThF5Pdnmbbv/zLFfgWKddeQHV/eNi1BG392hw4gEDh2sflMj8kmPJlT7+kVMA==
15033+
qunit@^2.14.1, qunit@^2.16.0:
15034+
version "2.17.2"
15035+
resolved "https://registry.yarnpkg.com/qunit/-/qunit-2.17.2.tgz#5cb278e131d931f25c109a0fdb0518be7754c25a"
15036+
integrity sha512-17isVvuOmALzsPjiV7wFg/6O5vJYXBrQZPwocfQSSh0I/rXvfX7bKMFJ4GMVW3U4P8r2mBeUy8EAngti4QD2Vw==
1508315037
dependencies:
15084-
commander "7.1.0"
15085-
node-watch "0.7.1"
15038+
commander "7.2.0"
15039+
node-watch "0.7.2"
1508615040
tiny-glob "0.2.9"
1508715041

1508815042
randombytes@^2.0.0, randombytes@^2.0.1, randombytes@^2.0.5, randombytes@^2.1.0:
@@ -15780,7 +15734,7 @@ rsvp@^3.0.14, rsvp@^3.0.17, rsvp@^3.0.18, rsvp@^3.0.21, rsvp@^3.0.6, rsvp@^3.1.0
1578015734
resolved "https://registry.yarnpkg.com/rsvp/-/rsvp-3.6.2.tgz#2e96491599a96cde1b515d5674a8f7a91452926a"
1578115735
integrity sha512-OfWGQTb9vnwRjwtA2QwpG2ICclHC3pgXZO5xt8H2EfgDquO0qVdSb5T88L4qJVAEugbS56pAuV4XZM58UX8ulw==
1578215736

15783-
rsvp@^4.0.1, rsvp@^4.6.1, rsvp@^4.7.0, rsvp@^4.8.0, rsvp@^4.8.1, rsvp@^4.8.2, rsvp@^4.8.3, rsvp@^4.8.4, rsvp@^4.8.5:
15737+
rsvp@^4.0.1, rsvp@^4.6.1, rsvp@^4.7.0, rsvp@^4.8.1, rsvp@^4.8.2, rsvp@^4.8.3, rsvp@^4.8.4, rsvp@^4.8.5:
1578415738
version "4.8.5"
1578515739
resolved "https://registry.yarnpkg.com/rsvp/-/rsvp-4.8.5.tgz#c8f155311d167f68f21e168df71ec5b083113734"
1578615740
integrity sha512-nfMOlASu9OnRJo1mbEk2cz0D56a1MBNrJ7orjRZQG10XDyuvwksKbuXNp6qa+kbn839HwjwhBzhFmdsaEAfauA==
@@ -16288,14 +16242,6 @@ source-map-support@^0.4.15:
1628816242
dependencies:
1628916243
source-map "^0.5.6"
1629016244

16291-
source-map-support@^0.5.0:
16292-
version "0.5.20"
16293-
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.20.tgz#12166089f8f5e5e8c56926b377633392dd2cb6c9"
16294-
integrity sha512-n1lZZ8Ve4ksRqizaBQgxXDgKwttHDhyfQjA6YZZn8+AroHbsIz+JjwxQDxbp+7y5OYCI8t1Yk7etjD9CRd2hIw==
16295-
dependencies:
16296-
buffer-from "^1.0.0"
16297-
source-map "^0.6.0"
16298-
1629916245
source-map-support@^0.5.16, source-map-support@^0.5.17, source-map-support@^0.5.6, source-map-support@~0.5.10, source-map-support@~0.5.12, source-map-support@~0.5.19:
1630016246
version "0.5.19"
1630116247
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61"

0 commit comments

Comments
 (0)