Skip to content

Commit 45d46de

Browse files
committed
update rollup config
1 parent c6ef0fe commit 45d46de

File tree

7 files changed

+289
-232
lines changed

7 files changed

+289
-232
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ cypress/report.json
55
cypress/screenshots/actual
66
cypress/videos/
77
dist/
8+
compiled/
89
yarn-error.log

.npmignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
pkg
22
src
33
node_modules
4-
coverage
4+
coverage
5+
compiled

package.json

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,27 @@
88
"build": "yarn clean && yarn typecheck && yarn bundle",
99
"bundle": "rollup -c rollup.config.ts",
1010
"clean": "rimraf ./dist ./compiled",
11-
"typecheck": "tsc --noEmit",
11+
"typecheck": "tsc -p ./tsconfig.build.json ",
1212
"test": "jest --notify --watch",
1313
"test:coverage": "jest --coverage",
1414
"test-ci": "grafana-toolkit plugin:test"
1515
},
16+
"publishConfig": {
17+
"main": "dist/index.js",
18+
"module": "dist/esm/index.js",
19+
"types": "dist/index.d.ts",
20+
"access": "public"
21+
},
1622
"files": [
1723
"index.js",
1824
"dist"
1925
],
2026
"repository": "github:grafana/grafana-async-query-support",
2127
"author": "Grafana Labs <team@grafana.com> (https://grafana.com)",
2228
"license": "Apache-2.0",
23-
"dependencies": {},
29+
"dependencies": {
30+
"tslib": "^2.4.1"
31+
},
2432
"devDependencies": {
2533
"@babel/preset-env": "^7.13.12",
2634
"@babel/preset-react": "^7.13.13",
@@ -29,9 +37,7 @@
2937
"@grafana/runtime": "8.4.7",
3038
"@grafana/toolkit": "8.4.7",
3139
"@grafana/ui": "8.4.7",
32-
"@rollup/plugin-commonjs": "11.0.2",
33-
"@rollup/plugin-json": "4.0.3",
34-
"@rollup/plugin-node-resolve": "7.1.1",
40+
"@rollup/plugin-node-resolve": "^15.0.1",
3541
"@testing-library/jest-dom": "^5.11.10",
3642
"@testing-library/react": "^11.2.5",
3743
"@testing-library/react-hooks": "^5.1.0",
@@ -47,16 +53,16 @@
4753
"@types/rollup-plugin-visualizer": "2.6.0",
4854
"@types/sinon": "^7.5.2",
4955
"babel-jest": "^26.6.3",
56+
"esbuild": "^0.15.13",
5057
"jest": "^26.6.3",
5158
"pretty-format": "25.1.0",
5259
"react-select-event": "^5.3.0",
5360
"react-test-renderer": "^17.0.2",
5461
"rimraf": "^3.0.2",
55-
"rollup": "2.0.6",
56-
"rollup-plugin-sourcemaps": "0.5.0",
57-
"rollup-plugin-terser": "5.3.0",
58-
"rollup-plugin-typescript2": "^0.29.0",
59-
"rollup-plugin-visualizer": "3.3.1",
62+
"rollup": "^2.79.1",
63+
"rollup-plugin-dts": "^5.0.0",
64+
"rollup-plugin-esbuild": "^4.10.1",
65+
"rollup-plugin-node-externals": "^5.0.2",
6066
"sinon": "8.1.1"
6167
},
6268
"resolutions": {

rollup.config.ts

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
import resolve from '@rollup/plugin-node-resolve';
2-
import commonjs from '@rollup/plugin-commonjs';
3-
import { terser } from 'rollup-plugin-terser';
4-
5-
import typescript from 'rollup-plugin-typescript2';
2+
import path from 'path';
3+
import dts from 'rollup-plugin-dts';
4+
import esbuild from 'rollup-plugin-esbuild';
5+
import { externals } from 'rollup-plugin-node-externals';
66

77
const pkg = require('./package.json');
88

9-
const libraryName = pkg.name;
10-
11-
const buildCjsPackage = ({ env }) => {
12-
return {
9+
export default [
10+
{
1311
input: 'src/index.ts',
12+
plugins: [
13+
externals({
14+
deps: true,
15+
include: ['react', '@grafana/data', '@grafana/ui', '@grafana/runtime', 'lodash', 'rxjs'],
16+
packagePath: './package.json',
17+
}),
18+
resolve(),
19+
esbuild(),
20+
],
1421
output: [
1522
{
16-
file: `dist/index.${env}.js`,
17-
name: libraryName,
1823
format: 'cjs',
1924
sourcemap: true,
20-
chunkFileNames: `[name].${env}.js`,
21-
strict: false,
22-
exports: 'named',
23-
globals: {
24-
react: 'React',
25-
'prop-types': 'PropTypes',
26-
},
25+
dir: path.dirname(pkg.publishConfig.main),
26+
},
27+
{
28+
format: 'esm',
29+
sourcemap: true,
30+
dir: path.dirname(pkg.publishConfig.module),
31+
preserveModules: true,
2732
},
2833
],
29-
external: ['react', '@grafana/data', '@grafana/ui', '@grafana/runtime', 'lodash', 'rxjs'],
30-
plugins: [
31-
typescript({
32-
rollupCommonJSResolveHack: false,
33-
clean: true,
34-
}),
35-
commonjs({
36-
include: /node_modules/,
37-
}),
38-
resolve(),
39-
env === 'production' && terser(),
40-
],
41-
};
42-
};
43-
export default [buildCjsPackage({ env: 'development' }), buildCjsPackage({ env: 'production' })];
34+
},
35+
{
36+
input: './compiled/index.d.ts',
37+
plugins: [dts()],
38+
output: {
39+
file: pkg.publishConfig.types,
40+
format: 'es',
41+
},
42+
},
43+
];

tsconfig.build.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"exclude": ["**/*.test.ts*", "**/*.test.tsx", "dist", "node_modules"],
3+
"extends": "./tsconfig.json"
4+
}

tsconfig.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
{
2-
"extends": "@grafana/tsconfig/base.json",
2+
"extends": "@grafana/tsconfig",
33
"include": ["src", "index.js"],
44
"compilerOptions": {
5-
"rootDir": "./src",
65
"baseUrl": "./src",
6+
"rootDir": "./src",
77
"typeRoots": ["./node_modules/@types"],
8-
"declaration": true,
9-
"outDir": "dist",
10-
"target": "es6"
8+
"declarationDir": "./compiled",
9+
"emitDeclarationOnly": true
1110
}
1211
}

0 commit comments

Comments
 (0)