mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-20 07:46:37 +00:00
Fix self-injection for custom polyfills (#20718)
* Fix self-injection for custom polyfills * Update build-scripts/bundle.cjs Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> --------- Co-authored-by: Paulus Schoutsen <balloob@gmail.com> Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
This commit is contained in:
parent
1925a47bdc
commit
84b436c08e
@ -3,6 +3,8 @@ const env = require("./env.cjs");
|
|||||||
const paths = require("./paths.cjs");
|
const paths = require("./paths.cjs");
|
||||||
const { dependencies } = require("../package.json");
|
const { dependencies } = require("../package.json");
|
||||||
|
|
||||||
|
const BABEL_PLUGINS = path.join(__dirname, "babel-plugins");
|
||||||
|
|
||||||
// GitHub base URL to use for production source maps
|
// GitHub base URL to use for production source maps
|
||||||
// Nightly builds use the commit SHA, otherwise assumes there is a tag that matches the version
|
// Nightly builds use the commit SHA, otherwise assumes there is a tag that matches the version
|
||||||
module.exports.sourceMapURL = () => {
|
module.exports.sourceMapURL = () => {
|
||||||
@ -100,22 +102,12 @@ module.exports.babelOptions = ({ latestBuild, isProdBuild, isTestBuild }) => ({
|
|||||||
],
|
],
|
||||||
plugins: [
|
plugins: [
|
||||||
[
|
[
|
||||||
path.resolve(
|
path.join(BABEL_PLUGINS, "inline-constants-plugin.cjs"),
|
||||||
paths.polymer_dir,
|
|
||||||
"build-scripts/babel-plugins/inline-constants-plugin.cjs"
|
|
||||||
),
|
|
||||||
{
|
{
|
||||||
modules: ["@mdi/js"],
|
modules: ["@mdi/js"],
|
||||||
ignoreModuleNotFound: true,
|
ignoreModuleNotFound: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
[
|
|
||||||
path.resolve(
|
|
||||||
paths.polymer_dir,
|
|
||||||
"build-scripts/babel-plugins/custom-polyfill-plugin.js"
|
|
||||||
),
|
|
||||||
{ method: "usage-global" },
|
|
||||||
],
|
|
||||||
// Minify template literals for production
|
// Minify template literals for production
|
||||||
isProdBuild && [
|
isProdBuild && [
|
||||||
"template-html-minifier",
|
"template-html-minifier",
|
||||||
@ -153,6 +145,17 @@ module.exports.babelOptions = ({ latestBuild, isProdBuild, isTestBuild }) => ({
|
|||||||
],
|
],
|
||||||
sourceMaps: !isTestBuild,
|
sourceMaps: !isTestBuild,
|
||||||
overrides: [
|
overrides: [
|
||||||
|
{
|
||||||
|
// Add plugin to inject various polyfills, excluding the polyfills
|
||||||
|
// themselves to prevent self- injection.
|
||||||
|
plugins: [
|
||||||
|
[
|
||||||
|
path.join(BABEL_PLUGINS, "custom-polyfill-plugin.js"),
|
||||||
|
{ method: "usage-global" },
|
||||||
|
],
|
||||||
|
],
|
||||||
|
exclude: /\/node_modules\/(?:unfetch|proxy-polyfill)\//,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
// Use unambiguous for dependencies so that require() is correctly injected into CommonJS files
|
// Use unambiguous for dependencies so that require() is correctly injected into CommonJS files
|
||||||
// Exclusions are needed in some cases where ES modules have no static imports or exports, such as polyfills
|
// Exclusions are needed in some cases where ES modules have no static imports or exports, such as polyfills
|
||||||
|
Loading…
x
Reference in New Issue
Block a user