diff --git a/static/jest.config.js b/static/jest.config.js index e5a7e560a4..4e7418a649 100644 --- a/static/jest.config.js +++ b/static/jest.config.js @@ -4,6 +4,11 @@ module.exports = { preset: "ts-jest/presets/js-with-ts", globals: { google: {}, + "ts-jest": { + tsconfig: { + module: "commonjs", + }, + }, }, testEnvironment: "jest-environment-jsdom", }; diff --git a/static/js/i18n/i18n.tsx b/static/js/i18n/i18n.tsx index b48b5f06ca..dd13236aea 100644 --- a/static/js/i18n/i18n.tsx +++ b/static/js/i18n/i18n.tsx @@ -42,7 +42,7 @@ let intl: IntlShape = createIntl({ locale: "en", messages: {} }, intlCache); */ function loadLocaleData( locale: string, - modules: Promise>[] + modules: (Promise> | Record)[] ): Promise { const allMessages = {}; // If no i18n modules are provided, just set the locale and return. @@ -54,7 +54,7 @@ function loadLocaleData( return Promise.all(modules) .then((messages) => { for (const msg of messages) { - Object.assign(allMessages, msg.default); + Object.assign(allMessages, msg.default || msg); } intl = createIntl({ locale, messages: allMessages }, intlCache); }) diff --git a/static/js/shared/util.ts b/static/js/shared/util.ts index 4f06bcf452..4b24013195 100644 --- a/static/js/shared/util.ts +++ b/static/js/shared/util.ts @@ -16,7 +16,6 @@ import axios from "axios"; import _ from "lodash"; -import { URLSearchParams } from "url"; import { AutoCompleteResult } from "../components/nl_search_bar/auto_complete_input"; import { Theme } from "../theme/types"; diff --git a/static/tsconfig.json b/static/tsconfig.json index b499ae8d03..e6ad0d97b8 100644 --- a/static/tsconfig.json +++ b/static/tsconfig.json @@ -9,8 +9,8 @@ "outDir": "./dist/", "sourceMap": true, "noImplicitAny": false, - "module": "CommonJS", - "target": "es6", + "module": "esnext", + "target": "es2021", "jsx": "react-jsx", "jsxImportSource": "@emotion/react", "allowJs": true, @@ -19,6 +19,11 @@ "moduleResolution": "node", "experimentalDecorators": true }, + "ts-node": { + "compilerOptions": { + "module": "commonjs" + } + }, "exclude": [ "node_modules", "./**/*.test.ts", diff --git a/static/webpack.config.js b/static/webpack.config.js index 7c7aeed990..52014571a1 100644 --- a/static/webpack.config.js +++ b/static/webpack.config.js @@ -200,6 +200,12 @@ const config = { }, ], }, + { + test: /\.m?js/, + resolve: { + fullySpecified: false, + }, + }, ], }, plugins: [