Skip to content

Commit 4dbf1c1

Browse files
chore: upgrade to rollup 4.x
1 parent 8b2b1a4 commit 4dbf1c1

File tree

4 files changed

+2125
-1909
lines changed

4 files changed

+2125
-1909
lines changed

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"version": "1.2.0",
55
"scripts": {
66
"clean": "shx rm -rf lib lib-esm _bundles",
7-
"build": "npm run compile && rollup -c && rollup -c --environment MINIFY",
7+
"build": "npm run compile && rollup -c rollup.config.mjs && rollup -c rollup.config.mjs --environment MINIFY",
88
"compile": "npm run clean && tsc && tsc -m es6 --outDir lib-esm",
99
"test": "jest",
1010
"test:downstream": "test_downstream_projects",
@@ -47,6 +47,8 @@
4747
"@uirouter/core": ">=5.0.0"
4848
},
4949
"devDependencies": {
50+
"@rollup/plugin-node-resolve": "^16.0.3",
51+
"@rollup/plugin-terser": "^0.4.4",
5052
"@types/jest": "^30.0.0",
5153
"@types/jquery": "^3.3.38",
5254
"@types/lodash": "^4.14.152",
@@ -63,10 +65,7 @@
6365
"lodash": "^4.17.11",
6466
"prettier": "^2.0.5",
6567
"pretty-quick": "^2.0.1",
66-
"rollup": "^2.10.9",
67-
"rollup-plugin-node-resolve": "^5.2.0",
68-
"rollup-plugin-sourcemaps": "^0.6.2",
69-
"rollup-plugin-uglify": "^6.0.1",
68+
"rollup": "^4.54.0",
7069
"ts-jest": "^29.4.6",
7170
"typescript": "^5.9.3"
7271
},

rollup.config.js

Lines changed: 0 additions & 38 deletions
This file was deleted.

rollup.config.mjs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import nodeResolve from '@rollup/plugin-node-resolve';
2+
import terser from '@rollup/plugin-terser';
3+
import { readFileSync } from 'fs';
4+
5+
const MINIFY = process.env.MINIFY;
6+
7+
const pkg = JSON.parse(readFileSync('./package.json', 'utf-8'));
8+
const banner = `/**
9+
* ${pkg.description}
10+
* @version v${pkg.version}
11+
* @link ${pkg.homepage}
12+
* @license MIT License, http://www.opensource.org/licenses/MIT
13+
*/`;
14+
15+
const terserOpts = {
16+
output: {
17+
// retain multiline comment with @license
18+
comments: (node, comment) => comment.type === 'comment2' && /@license/i.test(comment.value),
19+
},
20+
};
21+
22+
const plugins = [nodeResolve()];
23+
24+
if (MINIFY) plugins.push(terser(terserOpts));
25+
26+
const extension = MINIFY ? '.min.js' : '.js';
27+
28+
export default {
29+
input: 'lib-esm/index.js',
30+
output: {
31+
name: pkg.name,
32+
globals: { '@uirouter/core': '@uirouter/core' },
33+
sourcemap: true,
34+
format: 'umd',
35+
exports: 'named',
36+
banner: banner,
37+
file: '_bundles/ui-router-dsr' + extension,
38+
},
39+
external: ['@uirouter/core'],
40+
plugins: plugins,
41+
};

0 commit comments

Comments
 (0)