Skip to content

Commit 2da276a

Browse files
authored
fix: support new syntax in webpack@4 (#219)
webpack/webpack#10227
1 parent 361a41f commit 2da276a

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

src/index.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,14 @@ module.exports = {
5050
[
5151
require.resolve('@babel/plugin-proposal-class-properties'),
5252
{ loose: true }
53-
]
53+
],
54+
55+
// https://github.com/webpack/webpack/issues/10227
56+
// Remove when `ember-auto-import` updates to `webpack@5`.
57+
require.resolve(
58+
'@babel/plugin-proposal-nullish-coalescing-operator'
59+
),
60+
require.resolve('@babel/plugin-proposal-optional-chaining')
5461
],
5562
presets: [
5663
// Transpile incompatible syntax for project build targets

src/package.json

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
"dependencies": {
1919
"@babel/plugin-proposal-class-properties": "^7.12.1",
2020
"@babel/plugin-proposal-decorators": "^7.12.1",
21+
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.12.1",
22+
"@babel/plugin-proposal-optional-chaining": "^7.12.1",
2123
"@babel/plugin-transform-typescript": "^7.12.1",
2224
"@babel/preset-env": "^7.12.1"
2325
},
+2-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { module, test } from 'qunit';
22

3-
import { works, SomeEnum, moduleB } from '@test/ts-module-a';
3+
import { works, SomeEnum, moduleB, foo } from '@test/ts-module-a';
44

55
module('ts-module-a', function () {
66
test('it works', function (assert) {
77
assert.ok(works());
88
assert.ok('Foo' in SomeEnum);
99
assert.ok('Bar' in SomeEnum);
1010
assert.ok(moduleB.nestedWorks());
11+
assert.ok(foo === 'foo');
1112
});
1213
});

tests/ts-module-a/index.ts

+8
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,12 @@ export class SomeClass {
1515
declare someDeclaredProperty: true;
1616
}
1717

18+
declare global {
19+
interface Window {
20+
foo?: { bar?: string };
21+
}
22+
}
23+
24+
export const foo = window.foo?.bar ?? 'foo';
25+
1826
export type { SomeType } from './types-only';

0 commit comments

Comments
 (0)