Skip to content

Commit d111db3

Browse files
committed
Fix LOG_VERSIONS
Ember's debug logging of its own version was accidentally broken since 5.10 when we reformed the build. The problem was: - we switched to typescript's more spec-compliant class field semantics, where fields without `declare` are in fact present as real class fields with an undefined initializer. - our test suite was accidentally getting processed by vite's default (and pretty broken!) esbuild TS loader, which uses the loose & wrong field semantics. - `logVersions` in `class Libraries` is written in a picky way that breaks if you get the spec-compliant field semantics. This PR disables vite's built-in esbuild, which revealed the bug. The change to logVersions is the only real user-facing bugfix. There were also some similar bugs in the test suite itself which are fixed here. (All of this was precipated by me working on stable decorators, which *also* requires disabling vite's hidden-and-terrible TS support.)
1 parent 4e90280 commit d111db3

File tree

5 files changed

+16
-15
lines changed

5 files changed

+16
-15
lines changed

packages/@ember/-internals/metal/lib/libraries.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ export class Libraries {
6969
}
7070
}
7171

72-
isRegistered?: (name: string) => boolean;
73-
logVersions?: () => void;
72+
declare isRegistered?: (name: string) => boolean;
73+
declare logVersions?: () => void;
7474
}
7575

7676
if (DEBUG) {

packages/@ember/routing/tests/location/hash_location_test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ import { moduleFor, AbstractTestCase } from 'internal-test-helpers';
66
let location;
77

88
function createLocation(options, assert) {
9-
let HashTestLocation = HashLocation.extend({
10-
_location: {
9+
class HashTestLocation extends HashLocation {
10+
_location = {
1111
href: 'http://test.com/',
1212
pathname: '/',
1313
hash: '',
1414
search: '',
1515
replace() {
1616
assert.ok(false, 'location.replace should not be called during testing');
1717
},
18-
},
19-
});
18+
};
19+
}
2020

2121
if (!options) {
2222
options = {};

packages/@ember/routing/tests/location/history_location_test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ moduleFor(
5252
},
5353
};
5454

55-
HistoryTestLocation = HistoryLocation.extend({
56-
history: FakeHistory,
57-
});
55+
HistoryTestLocation = class extends HistoryLocation {
56+
history = FakeHistory;
57+
};
5858
}
5959

6060
teardown() {

packages/ember/tests/routing/decoupled_basic_test.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -987,15 +987,15 @@ moduleFor(
987987
let rootURL = '/blahzorz';
988988
this.add(
989989
'location:history-test',
990-
HistoryLocation.extend({
991-
rootURL: 'this is not the URL you are looking for',
992-
history: {
990+
class extends HistoryLocation {
991+
rootURL = 'this is not the URL you are looking for';
992+
history = {
993993
pushState() {},
994-
},
994+
};
995995
initState() {
996996
assert.equal(this.get('rootURL'), rootURL);
997-
},
998-
})
997+
}
998+
}
999999
);
10001000

10011001
this.router.reopen({

vite.config.mjs

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export default defineConfig(({ mode }) => {
4343
optimizeDeps: { noDiscovery: true },
4444
publicDir: 'tests/public',
4545
build,
46+
esbuild: false
4647
};
4748
});
4849

0 commit comments

Comments
 (0)