From 19f754f2ae3656d9936ed21c7f720c64c2635428 Mon Sep 17 00:00:00 2001 From: Martin Schuhfuss Date: Tue, 30 Sep 2025 19:54:54 +0200 Subject: [PATCH] chore: update and simplify rollup configuration This updates the browser list to be more in line with the official browser support policy of the Google Maps JavaScript API and simplifies the rollup configuration and build process. --- .babelrc | 3 --- package.json | 8 ++++++-- rollup.config.js | 28 +++++++++++----------------- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/.babelrc b/.babelrc index b7634ea0..093068f5 100644 --- a/.babelrc +++ b/.babelrc @@ -3,9 +3,6 @@ [ "@babel/env", { - "targets": { - "browsers": "ie>=11, > 0.25%, not dead" - }, "corejs": "3.6", "useBuiltIns": "usage" } diff --git a/package.json b/package.json index bfde7316..f3ead123 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "prepack": "npm run build", "lint": "eslint .", "test": "NODE_OPTIONS='--experimental-vm-modules --disable-warning=ExperimentalWarning' jest ./src", - "build": "rm -rf ./dist && rollup -c && rm -rf ./dist/types", + "build": "rm -rf ./dist && rollup -c", "format": "eslint . --fix" }, "dependencies": { @@ -76,5 +76,9 @@ }, "prettier": { "trailingComma": "es5" - } + }, + "browserslist": [ + "last 2 versions", + "not dead" + ] } diff --git a/rollup.config.js b/rollup.config.js index 089dc5de..9fd0f7b0 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -28,26 +28,23 @@ const terserOptions = { const basePlugins = [ typescript({ + declaration: false, tsconfig: "./tsconfig.build.json", - declaration: true, - declarationDir: "dist/types", - }), - nodeResolve({ - mainFields: ["browser", "jsnext:main", "module", "main"], }), + nodeResolve(), commonjs(), - babel({ - extensions: [".js", ".ts"], - babelHelpers: "bundled", - }), ]; export default [ - // UMD and browser (iife) builds + // CJS/UMD build { input: "src/index.ts", plugins: [ ...basePlugins, + babel({ + extensions: [".js", ".ts"], + babelHelpers: "bundled", + }), replace({ preventAssignment: true, values: { @@ -66,16 +63,12 @@ export default [ }, ], }, + // ESM build { input: "src/index.ts", plugins: [ - typescript({ - tsconfig: "./tsconfig.build.json", - declaration: false, - }), - nodeResolve(), - commonjs(), + ...basePlugins, replace({ preventAssignment: true, values: { @@ -90,9 +83,10 @@ export default [ exports: "named", }, }, + // types { - input: "./dist/types/index.d.ts", + input: "src/index.ts", output: [{ file: "dist/index.d.ts", format: "es" }], plugins: [dts()], },