From de1304d19e8436427cfa7cb660861f373cd32a18 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Mon, 30 Oct 2023 10:44:18 +0100 Subject: [PATCH] fix: use globalThis instead of self to address non Browser consumption Currently using this package in a non Browser env will cause an error as Webpack will emit `self` which does not exist in all envs such as Node.js and Workers. This commit updates Webpack and force it to use `globalThis`. See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis --- webpack.config.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index ca7c059a..3769bfb0 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -39,8 +39,10 @@ const config = { output: { filename: 'xterm.js', path: path.resolve('./lib'), - libraryTarget: 'umd' + libraryTarget: 'umd', + // Force usage of globalThis instead of global / self. (This is cross-env compatible) + globalObject: 'globalThis', }, - mode: 'production' + mode: 'production', }; module.exports = config;