From 2da276a4aa8e3fdc45804aaf9485e980837bd347 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Buscht=C3=B6ns?= Date: Tue, 27 Oct 2020 16:34:34 +0100 Subject: [PATCH] fix: support new syntax in `webpack@4` (#219) https://github.com/webpack/webpack/issues/10227 --- src/index.js | 9 ++++++++- src/package.json | 2 ++ tests/app/tests/unit/ts-module-a-test.js | 3 ++- tests/ts-module-a/index.ts | 8 ++++++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 306fbf2..60bea44 100644 --- a/src/index.js +++ b/src/index.js @@ -50,7 +50,14 @@ module.exports = { [ require.resolve('@babel/plugin-proposal-class-properties'), { loose: true } - ] + ], + + // https://github.com/webpack/webpack/issues/10227 + // Remove when `ember-auto-import` updates to `webpack@5`. + require.resolve( + '@babel/plugin-proposal-nullish-coalescing-operator' + ), + require.resolve('@babel/plugin-proposal-optional-chaining') ], presets: [ // Transpile incompatible syntax for project build targets diff --git a/src/package.json b/src/package.json index fc14cf8..a1b4d4c 100644 --- a/src/package.json +++ b/src/package.json @@ -18,6 +18,8 @@ "dependencies": { "@babel/plugin-proposal-class-properties": "^7.12.1", "@babel/plugin-proposal-decorators": "^7.12.1", + "@babel/plugin-proposal-nullish-coalescing-operator": "^7.12.1", + "@babel/plugin-proposal-optional-chaining": "^7.12.1", "@babel/plugin-transform-typescript": "^7.12.1", "@babel/preset-env": "^7.12.1" }, diff --git a/tests/app/tests/unit/ts-module-a-test.js b/tests/app/tests/unit/ts-module-a-test.js index bd557d0..0ebea40 100644 --- a/tests/app/tests/unit/ts-module-a-test.js +++ b/tests/app/tests/unit/ts-module-a-test.js @@ -1,6 +1,6 @@ import { module, test } from 'qunit'; -import { works, SomeEnum, moduleB } from '@test/ts-module-a'; +import { works, SomeEnum, moduleB, foo } from '@test/ts-module-a'; module('ts-module-a', function () { test('it works', function (assert) { @@ -8,5 +8,6 @@ module('ts-module-a', function () { assert.ok('Foo' in SomeEnum); assert.ok('Bar' in SomeEnum); assert.ok(moduleB.nestedWorks()); + assert.ok(foo === 'foo'); }); }); diff --git a/tests/ts-module-a/index.ts b/tests/ts-module-a/index.ts index b792c20..8263930 100644 --- a/tests/ts-module-a/index.ts +++ b/tests/ts-module-a/index.ts @@ -15,4 +15,12 @@ export class SomeClass { declare someDeclaredProperty: true; } +declare global { + interface Window { + foo?: { bar?: string }; + } +} + +export const foo = window.foo?.bar ?? 'foo'; + export type { SomeType } from './types-only';