Switch element-web to ESM (#31977)

* Switch element-web to ESM

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Update testcontainers imports

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Fix modernizr cjs

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Fix modernizr cjs ignore files

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Move modernizr sonar exclusion to exclude everything

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Update playwright tests for esm compat

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

---------

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2026-02-09 08:39:11 +00:00 committed by GitHub
parent de8ed98b53
commit c2f1793bb0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
24 changed files with 34 additions and 22 deletions

View File

@ -1,4 +1,4 @@
src/vector/modernizr.js
src/vector/modernizr.cjs
test/end-to-end-tests/node_modules/
test/end-to-end-tests/element/
test/end-to-end-tests/synapse/

View File

@ -21,7 +21,7 @@ electron/pub
/build_config.yaml
# Raises an error because it contains a template var breaking the script tag
src/vector/index.html
src/vector/modernizr.js
src/vector/modernizr.cjs
/docs/lib
/book
/debian/tmp

View File

@ -1 +0,0 @@
module.exports = require("eslint-plugin-matrix-org/.prettierrc.js");

View File

@ -43,7 +43,7 @@ const config: Config = {
"@vector-im/compound-web": "<rootDir>/node_modules/@vector-im/compound-web",
},
transformIgnorePatterns: [
"/node_modules/(?!(mime|matrix-js-sdk|uuid|p-retry|is-network-error|react-merge-refs|is-ip|ip-regex|super-regex|function-timeout|time-span|convert-hrtime|clone-regexp|is-regexp|matrix-web-i18n|await-lock|@element-hq/web-shared-components|react-virtuoso)).+$",
"/node_modules/(?!(mime|matrix-js-sdk|uuid|p-retry|is-network-error|react-merge-refs|is-ip|ip-regex|super-regex|function-timeout|time-span|convert-hrtime|clone-regexp|is-regexp|matrix-web-i18n|await-lock|@element-hq/web-shared-components|react-virtuoso|lodash)).+$",
],
collectCoverageFrom: [
"<rootDir>/src/**/*.{js,ts,tsx}",

View File

@ -8,6 +8,7 @@
"url": "https://github.com/element-hq/element-web"
},
"license": "SEE LICENSE IN README.md",
"type": "module",
"files": [
"lib",
"res",
@ -40,7 +41,7 @@
"build-stats": "yarn clean && yarn build:genfiles && yarn build:bundle-stats",
"build:res": "node scripts/copy-res.ts",
"build:genfiles": "yarn build:res && yarn build:module_system",
"build:modernizr": "modernizr -c .modernizr.json -d src/vector/modernizr.js",
"build:modernizr": "modernizr -c .modernizr.json -d src/vector/modernizr.js && mv src/vector/modernizr.js src/vector/modernizr.cjs",
"build:bundle": "webpack --progress --mode production",
"build:bundle-stats": "webpack --progress --mode production --json > webpack-stats.json",
"build:module_system": "node module_system/scripts/install.ts",
@ -126,7 +127,7 @@
"linkify-react": "4.3.2",
"linkify-string": "4.3.2",
"linkifyjs": "4.3.2",
"lodash": "^4.17.21",
"lodash": "npm:lodash-es@^4.17.21",
"maplibre-gl": "^5.0.0",
"matrix-encrypt-attachment": "^1.0.3",
"matrix-js-sdk": "github:matrix-org/matrix-js-sdk#develop",

View File

@ -55,7 +55,7 @@
"@vector-im/compound-design-tokens": "^6.4.3",
"classnames": "^2.5.1",
"counterpart": "^0.18.6",
"lodash": "^4.17.21",
"lodash": "npm:lodash-es@^4.17.21",
"matrix-web-i18n": "3.6.0",
"react-merge-refs": "^3.0.2",
"react-virtuoso": "^4.14.0",

View File

@ -4983,10 +4983,10 @@ lodash.merge@^4.6.2:
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a"
integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==
lodash@^4.17.15, lodash@^4.17.21, lodash@~4.17.15:
lodash@^4.17.15, lodash@^4.17.21, "lodash@npm:lodash-es@^4.17.21", lodash@~4.17.15:
version "4.17.23"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.23.tgz#f113b0378386103be4f6893388c73d0bde7f2c5a"
integrity sha512-LgVTMpQtIopCi79SJeDiP0TfWi5CNEc/L/aRdTh3yIvmZXTnheWpKjSZhnvMl8iXbC1tFg9gdHHDMLoV7CnG+w==
resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.23.tgz#58c4360fd1b5d33afc6c0bbd3d1149349b1138e0"
integrity sha512-kVI48u3PZr38HdYz98UmfPnXl2DXrpdctLrFLCd3kOx1xUkOmpFPx7gCWWM5MPkL/fD8zb+Ph0QzjGFs4+hHWg==
long@^5.0.0:
version "5.3.2"

View File

@ -8,9 +8,13 @@ Please see LICENSE files in the repository root for full details.
import path from "path";
import { readFile } from "node:fs/promises";
import { dirname } from "node:path";
import { fileURLToPath } from "node:url";
import { expect, test } from "../../element-web-test";
const __dirname = dirname(fileURLToPath(import.meta.url));
test.describe("migration", { tag: "@no-webkit" }, function () {
test.use({
displayName: "Alice",

View File

@ -6,7 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Com
Please see LICENSE files in the repository root for full details.
*/
import { type MailpitClient } from "@element-hq/element-web-playwright-common/lib/testcontainers";
import { type MailpitClient } from "@element-hq/element-web-playwright-common/lib/testcontainers/index.js";
import { type Page } from "@playwright/test";
import { expect } from "../../element-web-test";

View File

@ -6,7 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Com
Please see LICENSE files in the repository root for full details.
*/
import { type SynapseContainer } from "@element-hq/element-web-playwright-common/lib/testcontainers";
import { type SynapseContainer } from "@element-hq/element-web-playwright-common/lib/testcontainers/index.js";
import { type Fixtures } from "../../../element-web-test.ts";

View File

@ -11,6 +11,10 @@ import express from "express";
import { type AddressInfo } from "net";
import { type TestInfo } from "@playwright/test";
import { randB64Bytes } from "@element-hq/element-web-playwright-common/lib/utils/rand.js";
import { dirname } from "node:path";
import { fileURLToPath } from "node:url";
const __dirname = dirname(fileURLToPath(import.meta.url));
export class OAuthServer {
private server?: http.Server;

View File

@ -10,7 +10,7 @@ import {
type Services as BaseServices,
type WorkerOptions as BaseWorkerOptions,
} from "@element-hq/element-web-playwright-common/lib/fixtures";
import { type HomeserverContainer } from "@element-hq/element-web-playwright-common/lib/testcontainers";
import { type HomeserverContainer } from "@element-hq/element-web-playwright-common/lib/testcontainers/index.js";
import { type OAuthServer } from "./plugins/oauth_server";
import { DendriteContainer, PineconeContainer } from "./testcontainers/dendrite";

View File

@ -14,7 +14,7 @@ import {
StartedSynapseContainer,
type HomeserverContainer,
type StartedMatrixAuthenticationServiceContainer,
} from "@element-hq/element-web-playwright-common/lib/testcontainers";
} from "@element-hq/element-web-playwright-common/lib/testcontainers/index.js";
const DEFAULT_CONFIG = {
version: 2,

View File

@ -8,7 +8,7 @@ Please see LICENSE files in the repository root for full details.
import {
MatrixAuthenticationServiceContainer as BaseMatrixAuthenticationServiceContainer,
type StartedPostgreSqlContainer,
} from "@element-hq/element-web-playwright-common/lib/testcontainers";
} from "@element-hq/element-web-playwright-common/lib/testcontainers/index.js";
const TAG = "main@sha256:294e209b8e3c9dd0347e2baf01c34da9c6b0f27324ebccc5fbd6e221d08d16c3";

View File

@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Com
Please see LICENSE files in the repository root for full details.
*/
import { SynapseContainer as BaseSynapseContainer } from "@element-hq/element-web-playwright-common/lib/testcontainers";
import { SynapseContainer as BaseSynapseContainer } from "@element-hq/element-web-playwright-common/lib/testcontainers/index.js";
const TAG = "develop@sha256:f0de453dbb284112c4bc91be01345f189f218bf51ee09ed565dab295c0a72b44";

View File

@ -7,7 +7,7 @@ sonar.organization=element-hq
sonar.sources=src,res,packages/shared-components/src
sonar.tests=test,playwright,src,packages
sonar.test.inclusions=test/*,playwright/*,src/**/*.test.*,packages/*/src/**/*.test.*,packages/*/src/test/**/*
sonar.exclusions=__mocks__,docs,element.io,nginx
sonar.exclusions=__mocks__,docs,element.io,nginx,src/vector/modernizr.cjs
sonar.cpd.exclusions=src/i18n/strings/*.json
sonar.typescript.tsconfigPath=./tsconfig.json
@ -17,7 +17,6 @@ sonar.coverage.exclusions=\
playwright/**/*,\
res/**/*,\
scripts/**/*,\
src/vector/modernizr.js,\
src/components/views/dialogs/devtools/**/*,\
src/utils/SessionLock.ts,\
src/**/*.d.ts,\

View File

@ -15,7 +15,7 @@ import { shouldPolyfill as shouldPolyFillIntlSegmenter } from "@formatjs/intl-se
// These are things that can run before the skin loads - be careful not to reference the react-sdk though.
import { parseQsFromFragment } from "./url_utils";
import "./modernizr";
import "./modernizr.cjs";
// Import shared components CSS
import "@element-hq/web-shared-components/dist/element-web-shared-components.css";

View File

@ -1,5 +1,5 @@
/*!
* modernizr v3.13.0
* modernizr v3.13.1
* Build https://modernizr.com/download?-cors-cryptography-cssanimations-cssfilters-displaytable-es5date-es5function-es5object-es5undefined-es6array-es6collections-es6string-fetch-flexbox-json-localstorage-objectfit-promises-resizeobserver-sandbox-svg-svgasimg-svgfilters-urlparser-urlsearchparams-webaudio-dontmin
*
* Copyright (c)
@ -35,7 +35,7 @@
* @access public
*/
var ModernizrProto = {
_version: '3.13.0',
_version: '3.13.1',
// Any settings that don't work as separate modules
// can go in here as configuration.

View File

@ -413,7 +413,7 @@ module.exports = (env, argv) => {
type: "javascript/auto",
use: [
{
loader: path.resolve("./recorder-worklet-loader.js"),
loader: path.resolve("./recorder-worklet-loader.cjs"),
},
{
loader: "babel-loader",

View File

@ -9621,6 +9621,11 @@ lodash@^4.17.15, lodash@^4.17.20, lodash@^4.17.21:
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.23.tgz#f113b0378386103be4f6893388c73d0bde7f2c5a"
integrity sha512-LgVTMpQtIopCi79SJeDiP0TfWi5CNEc/L/aRdTh3yIvmZXTnheWpKjSZhnvMl8iXbC1tFg9gdHHDMLoV7CnG+w==
"lodash@npm:lodash-es@^4.17.21":
version "4.17.23"
resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.23.tgz#58c4360fd1b5d33afc6c0bbd3d1149349b1138e0"
integrity sha512-kVI48u3PZr38HdYz98UmfPnXl2DXrpdctLrFLCd3kOx1xUkOmpFPx7gCWWM5MPkL/fD8zb+Ph0QzjGFs4+hHWg==
log-update@^6.1.0:
version "6.1.0"
resolved "https://registry.yarnpkg.com/log-update/-/log-update-6.1.0.tgz#1a04ff38166f94647ae1af562f4bd6a15b1b7cd4"