Skip to content

Commit 3436cc0

Browse files
authored
fix: rollup configuration (#835)
This is a full refactoring of the rollup configuration to speed up builds, simplify the configuration prevent warnings and fix an error with the generated source maps. In detail: - refactor: Combine the three non-esm outputs into a single configuration. - feat: Enabled source-maps for all build outputs. - fix: Use a separate TypeScript configuration (`tsconfig.build.json`) during build. This configuration only compiles the required typescript files and doesn't reproduce the directory structure in the dist-folder (see also the change in package.json). It also now generates source maps correctly (#834). - chore: Moved `fast-deep-equal` from dependencies to devDependencies. It is a very small function, and it has always been bundled in all of our outputs, so it's not actually required at runtime. This will be changed in the next major release. fixes #834
1 parent 6e509b5 commit 3436cc0

File tree

4 files changed

+79
-56
lines changed

4 files changed

+79
-56
lines changed

package-lock.json

+35-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"main": "dist/index.umd.js",
2121
"unpkg": "dist/index.min.js",
2222
"module": "dist/index.mjs",
23-
"types": "dist/src/index.d.ts",
23+
"types": "dist/index.d.ts",
2424
"files": [
2525
"dist/",
2626
"src/"
@@ -33,9 +33,7 @@
3333
"test": "jest src/*",
3434
"test:e2e": "jest e2e/*"
3535
},
36-
"dependencies": {
37-
"fast-deep-equal": "^3.1.3"
38-
},
36+
"dependencies": {},
3937
"devDependencies": {
4038
"@babel/preset-env": "^7.9.5",
4139
"@babel/runtime-corejs3": "^7.9.2",
@@ -54,6 +52,7 @@
5452
"eslint-config-prettier": "^9.0.0",
5553
"eslint-plugin-jest": "^27.4.0",
5654
"eslint-plugin-prettier": "^5.0.0",
55+
"fast-deep-equal": "^3.1.3",
5756
"geckodriver": "^4.2.1",
5857
"jest": "^29.7.0",
5958
"jest-environment-jsdom": "^29.7.0",

rollup.config.mjs

+35-51
Original file line numberDiff line numberDiff line change
@@ -20,71 +20,55 @@ import { nodeResolve } from "@rollup/plugin-node-resolve";
2020
import terser from "@rollup/plugin-terser";
2121
import typescript from "@rollup/plugin-typescript";
2222

23-
const babelOptions = {
24-
extensions: [".js", ".ts"],
25-
};
26-
27-
const terserOptions = { output: { comments: "" } };
28-
29-
const resolveOptions = {
30-
mainFields: ["browser", "jsnext:main", "module", "main"],
23+
const terserOptions = {
24+
output: { comments: "some" },
3125
};
3226

3327
export default [
28+
// UMD and browser (iife) builds
3429
{
3530
input: "src/index.ts",
3631
plugins: [
37-
typescript({ tsconfig: "./tsconfig.json", declarationDir: "./" }),
38-
39-
nodeResolve(resolveOptions),
32+
typescript({ tsconfig: "./tsconfig.build.json", declarationDir: "./" }),
33+
nodeResolve({
34+
mainFields: ["browser", "jsnext:main", "module", "main"],
35+
}),
4036
commonjs(),
41-
babel(babelOptions),
42-
terser(terserOptions),
37+
babel({
38+
extensions: [".js", ".ts"],
39+
babelHelpers: "bundled",
40+
}),
4341
],
44-
output: {
45-
file: "dist/index.umd.js",
46-
format: "umd",
47-
name: "google.maps.plugins.loader",
48-
sourcemap: true,
49-
},
50-
},
51-
{
52-
input: "src/index.ts",
53-
plugins: [
54-
typescript({ tsconfig: "./tsconfig.json", declarationDir: "./" }),
55-
56-
nodeResolve(resolveOptions),
57-
commonjs(),
58-
babel(babelOptions),
59-
terser(terserOptions),
42+
output: [
43+
{
44+
file: "dist/index.umd.js",
45+
format: "umd",
46+
name: "google.maps.plugins.loader",
47+
sourcemap: true,
48+
plugins: [terser(terserOptions)],
49+
},
50+
{
51+
file: "dist/index.min.js",
52+
format: "iife",
53+
name: "google.maps.plugins.loader",
54+
sourcemap: true,
55+
plugins: [terser(terserOptions)],
56+
},
57+
{
58+
file: "dist/index.dev.js",
59+
format: "iife",
60+
name: "google.maps.plugins.loader",
61+
sourcemap: true,
62+
},
6063
],
61-
output: {
62-
file: "dist/index.min.js",
63-
format: "iife",
64-
name: "google.maps.plugins.loader",
65-
},
6664
},
67-
{
68-
input: "src/index.ts",
69-
plugins: [
70-
typescript({ tsconfig: "./tsconfig.json", declarationDir: "./" }),
7165

72-
nodeResolve(resolveOptions),
73-
commonjs(),
74-
babel(babelOptions),
75-
],
76-
output: {
77-
file: "dist/index.dev.js",
78-
format: "iife",
79-
name: "google.maps.plugins.loader",
80-
},
81-
},
66+
// ESM build
8267
{
8368
input: "src/index.ts",
8469
plugins: [
85-
typescript({ tsconfig: "./tsconfig.json", declarationDir: "./" }),
86-
87-
nodeResolve(resolveOptions),
70+
typescript({ tsconfig: "./tsconfig.build.json", declarationDir: "./" }),
71+
nodeResolve(),
8872
commonjs(),
8973
],
9074
output: {

tsconfig.build.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": { "noEmit": false },
4+
"include": ["src/**/*"],
5+
"exclude": ["node_modules", "./dist", "./e2e", "src/**/*.test.ts"]
6+
}

0 commit comments

Comments
 (0)