Skip to content

Commit 06b282f

Browse files
committed
Moving to Rollup typescript plugin
1 parent c781e5a commit 06b282f

File tree

8 files changed

+75
-149
lines changed

8 files changed

+75
-149
lines changed

generic-tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
{
22
"compilerOptions": {
3-
"target": "esnext",
3+
"target": "ESNext",
44
"module": "esnext",
55
"strict": true,
66
"moduleResolution": "node",
7-
"outDir": ".ts-tmp",
87
"composite": true,
98
"declarationMap": false,
109
"baseUrl": "./",

lib/simple-ts.js

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

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"@rollup/plugin-commonjs": "^28.0.3",
5656
"@rollup/plugin-node-resolve": "^16.0.1",
5757
"@rollup/plugin-terser": "^0.4.4",
58+
"@rollup/plugin-typescript": "^12.1.2",
5859
"@types/chai": "^5.2.2",
5960
"@types/mocha": "^10.0.10",
6061
"chai": "^5.2.0",
@@ -68,6 +69,7 @@
6869
"prettier": "^3.5.3",
6970
"rollup": "^4.40.2",
7071
"serve": "^14.2.4",
72+
"tslib": "^2.8.1",
7173
"typescript": "^5.8.3"
7274
},
7375
"husky": {

pnpm-lock.yaml

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rollup.config.js

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { promises as fsp } from 'fs';
22
import { basename } from 'path';
3-
import simpleTS from './lib/simple-ts.js';
4-
import {deleteAsync} from 'del';
3+
import { deleteAsync } from 'del';
54
import terser from '@rollup/plugin-terser';
65
import commonjs from '@rollup/plugin-commonjs';
76
import resolve from '@rollup/plugin-node-resolve';
87
import { getBabelOutputPlugin } from '@rollup/plugin-babel';
9-
import {glob} from 'glob';
8+
import typescript from '@rollup/plugin-typescript';
9+
10+
import { glob } from 'glob';
1011

1112
function addRedirectDeclaration(fileName) {
1213
return {
@@ -37,7 +38,7 @@ export default async function ({ watch }) {
3738
return {
3839
input: 'test/index.ts',
3940
plugins: [
40-
simpleTS('test', { watch }),
41+
typescript({ cacheDir: '.ts-tmp', tsconfig: './test/tsconfig.json' }),
4142
commonjs(),
4243
// When testing IE10
4344
// babel({
@@ -72,18 +73,17 @@ export default async function ({ watch }) {
7273
format: 'es',
7374
},
7475
],
75-
watch: {
76-
clearScreen: false,
77-
// Don't watch the ts files. Instead we watch the output from the ts compiler.
78-
exclude: ['**/*.ts', '**/*.tsx'],
79-
},
8076
};
8177

8278
return [
8379
// Main builds
8480
{
8581
input: 'src/index.ts',
86-
plugins: [simpleTS('src'), commonjs(), resolve()],
82+
plugins: [
83+
typescript({ cacheDir: '.ts-tmp', tsconfig: 'src/tsconfig.json' }),
84+
commonjs(),
85+
resolve(),
86+
],
8787
output: [
8888
{
8989
file: 'dist/index.js',
@@ -101,7 +101,11 @@ export default async function ({ watch }) {
101101
external: (id) => {
102102
if (id.startsWith('@babel/runtime')) return true;
103103
},
104-
plugins: [simpleTS('src', { noBuild: true }), commonjs(), resolve()],
104+
plugins: [
105+
typescript({ cacheDir: '.ts-tmp', tsconfig: 'src/tsconfig.json' }),
106+
commonjs(),
107+
resolve(),
108+
],
105109
output: [
106110
{
107111
file: 'dist/compat.js',
@@ -115,7 +119,11 @@ export default async function ({ watch }) {
115119
external: (id) => {
116120
if (id.startsWith('@babel/runtime')) return true;
117121
},
118-
plugins: [simpleTS('src', { noBuild: true }), commonjs(), resolve()],
122+
plugins: [
123+
typescript({ cacheDir: '.ts-tmp', tsconfig: 'src/tsconfig.json' }),
124+
commonjs(),
125+
resolve(),
126+
],
119127
output: [
120128
{
121129
file: 'dist/compat.cjs',
@@ -126,7 +134,11 @@ export default async function ({ watch }) {
126134
},
127135
{
128136
input: 'src/index.ts',
129-
plugins: [simpleTS('src', { noBuild: true }), commonjs(), resolve()],
137+
plugins: [
138+
typescript({ cacheDir: '.ts-tmp', tsconfig: 'src/tsconfig.json' }),
139+
commonjs(),
140+
resolve(),
141+
],
130142
output: [
131143
{
132144
file: 'dist/umd.js',

src/tsconfig.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
22
"extends": "../generic-tsconfig.json",
33
"compilerOptions": {
4-
"lib": ["esnext", "dom"]
4+
"lib": ["esnext", "dom"],
5+
"tsBuildInfoFile": "../.ts-tmp/.src.tsbuildinfo",
6+
"declarationDir": "../dist",
7+
"composite": true
58
}
69
}

test/index.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
setMany,
1414
update,
1515
getMany,
16-
delMany
16+
delMany,
1717
} from '../src';
1818
import { assert as typeAssert, IsExact } from 'conditional-type-checks';
1919

@@ -526,12 +526,12 @@ mocha.setup('tdd');
526526
[
527527
['hello', 'world'],
528528
[456, '789'],
529-
[1122, '3344']
529+
[1122, '3344'],
530530
],
531531
customStore,
532532
);
533533

534-
await delMany(['hello', 456], customStore)
534+
await delMany(['hello', 456], customStore);
535535

536536
assert.deepEqual(
537537
await entries(),
@@ -543,9 +543,7 @@ mocha.setup('tdd');
543543
);
544544
assert.deepEqual(
545545
await entries(customStore),
546-
[
547-
[1122, '3344']
548-
],
546+
[[1122, '3344']],
549547
`Selected custom store keys have been deleted`,
550548
);
551549
});

test/tsconfig.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
"extends": "../generic-tsconfig.json",
33
"compilerOptions": {
44
"esModuleInterop": true,
5-
"lib": ["esnext", "dom"]
5+
"lib": ["esnext", "dom"],
6+
"tsBuildInfoFile": "../.ts-tmp/.test.tsbuildinfo",
7+
"declarationDir": "../dist/test",
8+
"composite": true,
9+
"rootDir": "../"
610
},
7-
"references": [{ "path": "../src" }]
11+
"include": ["**/*.ts", "../src/**/*.ts"]
812
}

0 commit comments

Comments
 (0)