Skip to content

Commit a0a2e54

Browse files
authored
chore: Upgrade rollup-typescript (#6302)
1 parent a6f0da9 commit a0a2e54

File tree

12 files changed

+212
-208
lines changed

12 files changed

+212
-208
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,12 @@
9999
"@lerna-lite/cli": "^3.9.2",
100100
"@lerna-lite/publish": "^3.9.2",
101101
"@rollup/plugin-alias": "^5.1.1",
102-
"@rollup/plugin-commonjs": "^26.0.3",
102+
"@rollup/plugin-commonjs": "^28.0.0",
103103
"@rollup/plugin-json": "^6.1.0",
104104
"@rollup/plugin-multi-entry": "^6.0.1",
105105
"@rollup/plugin-node-resolve": "^15.3.0",
106106
"@rollup/plugin-terser": "^0.4.4",
107-
"@rollup/plugin-typescript": "^11.1.6",
107+
"@rollup/plugin-typescript": "^12.1.0",
108108
"@tsconfig/node18": "^18.2.4",
109109
"@types/node": "^18.19.54",
110110
"@vitest/coverage-istanbul": "^2.1.1",

pnpm-lock.yaml

+16-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
1+
// @ts-check
2+
import Path from 'node:path';
3+
14
import rollupPluginCommonjs from '@rollup/plugin-commonjs';
25
import rollupPluginJson from '@rollup/plugin-json';
36
import rollupPluginNodeResolve from '@rollup/plugin-node-resolve';
4-
import rollupPluginTerser from '@rollup/plugin-terser';
57
import rollupPluginTypescript from '@rollup/plugin-typescript';
6-
// import { readFileSync } from 'fs';
8+
9+
/** @typedef {import('rollup').RollupOptions} RollupOptions */
10+
/** @typedef {import('rollup').OutputOptions} OutputOptions */
11+
/** @typedef {import('@rollup/plugin-typescript').RollupTypescriptPluginOptions} RollupTypescriptPluginOptions */
712

813
// const pkg = JSON.parse(readFileSync('./package.json', 'utf-8'));
914

10-
/** @type {import('rollup').RollupOptions} */
15+
/** @type {RollupOptions} */
1116
const common = {
1217
input: 'src/index.ts',
1318

1419
output: {
1520
sourcemap: true,
1621
},
1722

18-
// external: ['@cspell/cspell-pipe', '@cspell/cspell-pipe/sync'],
19-
2023
treeshake: {
2124
annotations: true,
2225
moduleSideEffects: [],
@@ -25,13 +28,17 @@ const common = {
2528
},
2629
};
2730

31+
/** @type {RollupTypescriptPluginOptions} */
32+
const defaultTypeScriptConfig = { tsconfig: 'tsconfig.json' };
33+
2834
/**
2935
* Get new instances of all the common plugins.
36+
* @param {RollupTypescriptPluginOptions} typeScriptConfig
3037
*/
31-
function getPlugins(tsconfig = 'tsconfig.esm.json') {
38+
function getPlugins(typeScriptConfig = defaultTypeScriptConfig) {
3239
return [
3340
rollupPluginTypescript({
34-
tsconfig,
41+
...typeScriptConfig,
3542
}),
3643
rollupPluginNodeResolve({
3744
mainFields: ['module', 'exports', 'es', 'es6', 'esm', 'main'],
@@ -42,33 +49,23 @@ function getPlugins(tsconfig = 'tsconfig.esm.json') {
4249
transformMixedEsModules: true,
4350
}),
4451
rollupPluginJson(),
45-
rollupPluginTerser({
46-
ecma: 2020,
47-
compress: false,
48-
mangle: false,
49-
format: { ecma: 2020, beautify: true },
50-
}),
51-
// rollupPluginTerser({
52-
// ecma: 2018,
53-
// warnings: true,
54-
// compress: { drop_console: false },
55-
// format: { comments: false },
56-
// sourceMap: true,
57-
// }),
5852
];
5953
}
6054

61-
/** @type {import('rollup').RollupOptions[]} */
62-
const configs = [
63-
{
64-
...common,
65-
external: [],
66-
output: [
67-
{ ...common.output, file: './dist/rollup/cjs/index.cjs', format: 'cjs' },
68-
{ ...common.output, file: './dist/rollup/esm/index.mjs', format: 'es' },
69-
// { ...common.output, file: pkg.browser, format: 'umd', name: 'test-cspell-pipe-rollup' },
70-
],
71-
plugins: getPlugins(),
72-
},
55+
/** @type {OutputOptions[]} */
56+
const targets = [
57+
{ file: './dist/rollup/cjs/index.cjs', format: 'cjs' },
58+
{ file: './dist/rollup/esm/index.mjs', format: 'es' },
59+
// { file: pkg.browser, format: 'umd', name: 'test-cspell-pipe-rollup' },
7360
];
61+
62+
/** @type {import('rollup').RollupOptions[]} */
63+
const configs = targets.map((target) => ({
64+
...common,
65+
output: { ...common.output, ...target },
66+
plugins: getPlugins({
67+
tsconfig: 'tsconfig.json',
68+
compilerOptions: { outDir: (target.file && Path.dirname(target.file)) || undefined },
69+
}),
70+
}));
7471
export default configs;

test-packages/cspell-dictionary/test-cspell-dictionary/tsconfig.esm.json

-13
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
{
2-
"files": [],
3-
"references": [{ "path": "./tsconfig.esm.json" }]
2+
"extends": "../../../tsconfig.esm.json",
3+
"compilerOptions": {
4+
"module": "NodeNext",
5+
"moduleResolution": "NodeNext",
6+
"composite": true,
7+
"tsBuildInfoFile": "dist/compile.esm.tsbuildInfo",
8+
"rootDir": "src",
9+
"outDir": "dist/esm",
10+
"types": ["node"]
11+
},
12+
"include": ["src"]
413
}
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
1+
// @ts-check
2+
import Path from 'node:path';
3+
14
import rollupPluginCommonjs from '@rollup/plugin-commonjs';
25
import rollupPluginJson from '@rollup/plugin-json';
36
import rollupPluginNodeResolve from '@rollup/plugin-node-resolve';
4-
import rollupPluginTerser from '@rollup/plugin-terser';
57
import rollupPluginTypescript from '@rollup/plugin-typescript';
6-
// import { readFileSync } from 'fs';
8+
9+
/** @typedef {import('rollup').RollupOptions} RollupOptions */
10+
/** @typedef {import('rollup').OutputOptions} OutputOptions */
11+
/** @typedef {import('@rollup/plugin-typescript').RollupTypescriptPluginOptions} RollupTypescriptPluginOptions */
712

813
// const pkg = JSON.parse(readFileSync('./package.json', 'utf-8'));
914

10-
/** @type {import('rollup').RollupOptions} */
15+
/** @type {RollupOptions} */
1116
const common = {
1217
input: 'src/index.ts',
1318

1419
output: {
1520
sourcemap: true,
1621
},
1722

18-
// external: ['@cspell/cspell-pipe', '@cspell/cspell-pipe/sync'],
19-
2023
treeshake: {
2124
annotations: true,
2225
moduleSideEffects: [],
@@ -25,13 +28,17 @@ const common = {
2528
},
2629
};
2730

31+
/** @type {RollupTypescriptPluginOptions} */
32+
const defaultTypeScriptConfig = { tsconfig: 'tsconfig.json' };
33+
2834
/**
2935
* Get new instances of all the common plugins.
36+
* @param {RollupTypescriptPluginOptions} typeScriptConfig
3037
*/
31-
function getPlugins(tsconfig = 'tsconfig.esm.json') {
38+
function getPlugins(typeScriptConfig = defaultTypeScriptConfig) {
3239
return [
3340
rollupPluginTypescript({
34-
tsconfig,
41+
...typeScriptConfig,
3542
}),
3643
rollupPluginNodeResolve({
3744
mainFields: ['module', 'exports', 'es', 'es6', 'esm', 'main'],
@@ -42,33 +49,23 @@ function getPlugins(tsconfig = 'tsconfig.esm.json') {
4249
transformMixedEsModules: true,
4350
}),
4451
rollupPluginJson(),
45-
rollupPluginTerser({
46-
ecma: 2020,
47-
compress: false,
48-
mangle: false,
49-
format: { ecma: 2020, beautify: true },
50-
}),
51-
// rollupPluginTerser({
52-
// ecma: 2018,
53-
// warnings: true,
54-
// compress: { drop_console: false },
55-
// format: { comments: false },
56-
// sourceMap: true,
57-
// }),
5852
];
5953
}
6054

61-
/** @type {import('rollup').RollupOptions[]} */
62-
const configs = [
63-
{
64-
...common,
65-
external: [],
66-
output: [
67-
{ ...common.output, file: './dist/rollup/cjs/index.cjs', format: 'cjs' },
68-
{ ...common.output, file: './dist/rollup/esm/index.mjs', format: 'es' },
69-
// { ...common.output, file: pkg.browser, format: 'umd', name: 'test-cspell-pipe-rollup' },
70-
],
71-
plugins: getPlugins(),
72-
},
55+
/** @type {OutputOptions[]} */
56+
const targets = [
57+
{ file: './dist/rollup/cjs/index.cjs', format: 'cjs' },
58+
{ file: './dist/rollup/esm/index.mjs', format: 'es' },
59+
// { file: pkg.browser, format: 'umd', name: 'test-cspell-pipe-rollup' },
7360
];
61+
62+
/** @type {import('rollup').RollupOptions[]} */
63+
const configs = targets.map((target) => ({
64+
...common,
65+
output: { ...common.output, ...target },
66+
plugins: getPlugins({
67+
tsconfig: 'tsconfig.json',
68+
compilerOptions: { outDir: (target.file && Path.dirname(target.file)) || undefined },
69+
}),
70+
}));
7471
export default configs;

test-packages/cspell-gitignore/test-cspell-gitignore/tsconfig.esm.json

-13
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
{
2-
"files": [],
3-
"references": [{ "path": "./tsconfig.esm.json" }]
2+
"extends": "../../../tsconfig.esm.json",
3+
"compilerOptions": {
4+
"module": "NodeNext",
5+
"moduleResolution": "NodeNext",
6+
"composite": true,
7+
"tsBuildInfoFile": "dist/compile.esm.tsbuildInfo",
8+
"rootDir": "src",
9+
"outDir": "dist/esm",
10+
"types": ["node"]
11+
},
12+
"include": ["src"]
413
}

0 commit comments

Comments
 (0)