diff --git a/scripts/build.mjs b/scripts/build.mjs
index 7084ebc0..6b28d6aa 100644
--- a/scripts/build.mjs
+++ b/scripts/build.mjs
@@ -88,7 +88,7 @@ async function build() {
// so do it first
const themeAssets = await copyThemeAssets(themes, legacy);
const jsBundlePath = await buildJs("src/main.js", `${PROJECT_ID}.js`);
- const jsLegacyBundlePath = await buildJsLegacy("src/main.js", `${PROJECT_ID}-legacy.js`);
+ const jsLegacyBundlePath = await buildJsLegacy("src/main.js", `${PROJECT_ID}-legacy.js`, 'src/legacy-extras.js');
const jsWorkerPath = await buildWorkerJsLegacy("src/worker.js", `worker.js`);
const cssBundlePaths = await buildCssBundles(legacy ? buildCssLegacy : buildCss, themes, themeAssets);
@@ -185,7 +185,7 @@ async function buildHtml(doc, version, assetPaths, manifestPath) {
doc("script#main").replaceWith(
`` +
`` +
- ``);
+ ``);
removeOrEnableScript(doc("script#service-worker"), offline);
const versionScript = doc("script#version");
@@ -218,7 +218,7 @@ async function buildJs(inputFile, outputName) {
return bundlePath;
}
-async function buildJsLegacy(inputFile, outputName, polyfillFile = null) {
+async function buildJsLegacy(inputFile, outputName, extraFile, polyfillFile) {
// compile down to whatever IE 11 needs
const babelPlugin = babel.babel({
babelHelpers: 'bundled',
@@ -237,9 +237,13 @@ async function buildJsLegacy(inputFile, outputName, polyfillFile = null) {
if (!polyfillFile) {
polyfillFile = 'src/legacy-polyfill.js';
}
+ const inputFiles = [polyfillFile, inputFile];
+ if (extraFile) {
+ inputFiles.push(extraFile);
+ }
// create js bundle
const rollupConfig = {
- input: [polyfillFile, inputFile],
+ input: inputFiles,
plugins: [multi(), commonjs(), nodeResolve(), babelPlugin, removeJsComments({comments: "none"})]
};
const bundle = await rollup(rollupConfig);
@@ -255,7 +259,7 @@ async function buildJsLegacy(inputFile, outputName, polyfillFile = null) {
function buildWorkerJsLegacy(inputFile, outputName) {
const polyfillFile = 'src/worker-polyfill.js';
- return buildJsLegacy(inputFile, outputName, polyfillFile);
+ return buildJsLegacy(inputFile, outputName, null, polyfillFile);
}
async function buildOffline(version, assetPaths) {
diff --git a/src/legacy-extras.js b/src/legacy-extras.js
new file mode 100644
index 00000000..cadcbb48
--- /dev/null
+++ b/src/legacy-extras.js
@@ -0,0 +1,3 @@
+//import aesjs from "../lib/aes-js/index.js";
+let aesjs = "aesjs";
+export const legacyExtras = {aesjs};
diff --git a/src/main.js b/src/main.js
index 97c0b812..3c99f04f 100644
--- a/src/main.js
+++ b/src/main.js
@@ -78,7 +78,7 @@ async function loadOlmWorker(paths) {
// Don't use a default export here, as we use multiple entries during legacy build,
// which does not support default exports,
// see https://github.com/rollup/plugins/tree/master/packages/multi-entry
-export async function main(container, paths) {
+export async function main(container, paths, legacyExtras) {
try {
const isIE11 = !!window.MSInputMethodContext && !!document.documentMode;
if (isIE11) {