diff --git a/package-lock.json b/package-lock.json index 4bf88621..68cfe02e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,6 +13,7 @@ }, "devDependencies": { "@babel/preset-env": "^7.9.5", + "@babel/preset-modules": "^0.1.6", "@babel/runtime-corejs3": "^7.9.2", "@rollup/plugin-babel": "^6.0.3", "@rollup/plugin-commonjs": "^25.0.4", @@ -534,6 +535,23 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/@babel/plugin-proposal-unicode-property-regex": { + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.18.6.tgz", + "integrity": "sha512-2BShG/d5yoZyXZfVePH91urL5wTG6ASZU9M4o03lKK8u8UW1y08OMttBSOADTcJrnPMpvDXRG3G8fyLh4ovs8w==", + "deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-unicode-property-regex instead.", + "dev": true, + "dependencies": { + "@babel/helper-create-regexp-features-plugin": "^7.18.6", + "@babel/helper-plugin-utils": "^7.18.6" + }, + "engines": { + "node": ">=4" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, "node_modules/@babel/plugin-syntax-async-generators": { "version": "7.8.4", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz", @@ -1677,7 +1695,7 @@ "@babel/core": "^7.0.0-0" } }, - "node_modules/@babel/preset-modules": { + "node_modules/@babel/preset-env/node_modules/@babel/preset-modules": { "version": "0.1.6-no-external-plugins", "resolved": "https://registry.npmjs.org/@babel/preset-modules/-/preset-modules-0.1.6-no-external-plugins.tgz", "integrity": "sha512-HrcgcIESLm9aIR842yhJ5RWan/gebQUJ6E/E5+rf0y9o6oj7w0Br+sWuL6kEQ/o/AdfvR1Je9jG18/gnpwjEyA==", @@ -1691,6 +1709,22 @@ "@babel/core": "^7.0.0-0 || ^8.0.0-0 <8.0.0" } }, + "node_modules/@babel/preset-modules": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/@babel/preset-modules/-/preset-modules-0.1.6.tgz", + "integrity": "sha512-ID2yj6K/4lKfhuU3+EX4UvNbIt7eACFbHmNUjzA+ep+B5971CknnA/9DEWKbRokfbbtblxxxXFJJrH47UEAMVg==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/plugin-proposal-unicode-property-regex": "^7.4.4", + "@babel/plugin-transform-dotall-regex": "^7.4.4", + "@babel/types": "^7.4.4", + "esutils": "^2.0.2" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0 || ^8.0.0-0 <8.0.0" + } + }, "node_modules/@babel/regjsgen": { "version": "0.8.0", "resolved": "https://registry.npmjs.org/@babel/regjsgen/-/regjsgen-0.8.0.tgz", diff --git a/package.json b/package.json index 62aed264..d5ee2427 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "main": "dist/index.umd.js", "unpkg": "dist/index.min.js", "module": "dist/index.mjs", - "types": "dist/src/index.d.ts", + "types": "dist/index.d.ts", "files": [ "dist/", "src/" @@ -33,9 +33,7 @@ "test": "jest src/*", "test:e2e": "jest e2e/*" }, - "dependencies": { - "fast-deep-equal": "^3.1.3" - }, + "dependencies": {}, "devDependencies": { "@babel/preset-env": "^7.9.5", "@babel/runtime-corejs3": "^7.9.2", @@ -54,6 +52,7 @@ "eslint-config-prettier": "^9.0.0", "eslint-plugin-jest": "^27.4.0", "eslint-plugin-prettier": "^5.0.0", + "fast-deep-equal": "^3.1.3", "geckodriver": "^4.2.1", "jest": "^29.7.0", "jest-environment-jsdom": "^29.7.0", diff --git a/rollup.config.mjs b/rollup.config.mjs index f1b2a22c..ce6688fe 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -20,71 +20,55 @@ import { nodeResolve } from "@rollup/plugin-node-resolve"; import terser from "@rollup/plugin-terser"; import typescript from "@rollup/plugin-typescript"; -const babelOptions = { - extensions: [".js", ".ts"], -}; - -const terserOptions = { output: { comments: "" } }; - -const resolveOptions = { - mainFields: ["browser", "jsnext:main", "module", "main"], +const terserOptions = { + output: { comments: "some" }, }; export default [ + // UMD and browser (iife) builds { input: "src/index.ts", plugins: [ - typescript({ tsconfig: "./tsconfig.json", declarationDir: "./" }), - - nodeResolve(resolveOptions), + typescript({ tsconfig: "./tsconfig.build.json", declarationDir: "./" }), + nodeResolve({ + mainFields: ["browser", "jsnext:main", "module", "main"], + }), commonjs(), - babel(babelOptions), - terser(terserOptions), + babel({ + extensions: [".js", ".ts"], + babelHelpers: "bundled", + }), ], - output: { - file: "dist/index.umd.js", - format: "umd", - name: "google.maps.plugins.loader", - sourcemap: true, - }, - }, - { - input: "src/index.ts", - plugins: [ - typescript({ tsconfig: "./tsconfig.json", declarationDir: "./" }), - - nodeResolve(resolveOptions), - commonjs(), - babel(babelOptions), - terser(terserOptions), + output: [ + { + file: "dist/index.umd.js", + format: "umd", + name: "google.maps.plugins.loader", + sourcemap: true, + plugins: [terser(terserOptions)], + }, + { + file: "dist/index.min.js", + format: "iife", + name: "google.maps.plugins.loader", + sourcemap: true, + plugins: [terser(terserOptions)], + }, + { + file: "dist/index.dev.js", + format: "iife", + name: "google.maps.plugins.loader", + sourcemap: true, + }, ], - output: { - file: "dist/index.min.js", - format: "iife", - name: "google.maps.plugins.loader", - }, }, - { - input: "src/index.ts", - plugins: [ - typescript({ tsconfig: "./tsconfig.json", declarationDir: "./" }), - nodeResolve(resolveOptions), - commonjs(), - babel(babelOptions), - ], - output: { - file: "dist/index.dev.js", - format: "iife", - name: "google.maps.plugins.loader", - }, - }, + // ESM build { input: "src/index.ts", plugins: [ - typescript({ tsconfig: "./tsconfig.json", declarationDir: "./" }), - - nodeResolve(resolveOptions), + typescript({ tsconfig: "./tsconfig.build.json", declarationDir: "./" }), + nodeResolve(), commonjs(), ], output: { diff --git a/tsconfig.build.json b/tsconfig.build.json new file mode 100644 index 00000000..707c819e --- /dev/null +++ b/tsconfig.build.json @@ -0,0 +1,6 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { "noEmit": false }, + "include": ["src/**/*"], + "exclude": ["node_modules", "./dist", "./e2e", "src/**/*.test.ts"] +}