Skip to content

Commit af33064

Browse files
authored
Revamp build (#33)
* WIP build revamp * Refine types; add GitHub Actions workflow * Export types * Upgrade @orchidjs/unicode-variants
1 parent edaf386 commit af33064

15 files changed

+6396
-80
lines changed

.config/babel.config.json

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,11 @@
44
[
55
"@babel/preset-env",
66
{
7-
loose: true,
8-
bugfixes: true,
9-
modules: false
7+
"loose": true,
8+
"bugfixes": true,
9+
"modules": false
1010
}
1111
],
1212
"@babel/typescript"
13-
],
14-
"plugins": [
15-
["@babel/plugin-proposal-class-properties", { "loose": true }]
16-
]
13+
]
1714
}

.config/rollup.config.js renamed to .config/rollup.config.mjs

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import babel from '@rollup/plugin-babel';
2-
import { terser } from 'rollup-plugin-terser';
2+
import terser from '@rollup/plugin-terser';
33
import resolve from '@rollup/plugin-node-resolve'; // so Rollup can resolve imports without file extensions and `node_modules`
44
import path from 'path';
5+
import { fileURLToPath } from 'url';
56

6-
var configs = [];
7+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
8+
9+
const configs = [];
710
const banner = `/*! sifter.js | https://github.com/orchidjs/sifter.js | Apache License (v2) */`;
811

912
const extensions = [
@@ -36,33 +39,6 @@ var terser_config = terser({
3639
});
3740

3841

39-
// esm
40-
configs.push({
41-
input: path.resolve(__dirname,'../lib/sifter.ts'),
42-
output:{
43-
dir: path.resolve(__dirname,'../dist/esm'),
44-
format: 'esm',
45-
preserveModules: true,
46-
sourcemap: true,
47-
banner: banner,
48-
},
49-
plugins:[babel_config,resolve_config]
50-
});
51-
52-
// cjs
53-
configs.push({
54-
input: path.resolve(__dirname,'../lib/sifter.ts'),
55-
output:{
56-
dir: path.resolve(__dirname,'../dist/cjs'),
57-
format: 'cjs',
58-
preserveModules: false,
59-
sourcemap: true,
60-
banner: banner,
61-
},
62-
plugins:[babel_config,resolve_config]
63-
});
64-
65-
6642
// umd
6743
configs.push({
6844
input: path.resolve(__dirname,'../lib/sifter.ts'),

.config/tsconfig.cjs.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"module": "CommonJS",
5+
"moduleResolution": "Node",
6+
"outDir": "../dist/cjs",
7+
}
8+
}

.config/tsconfig.esm.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"module": "NodeNext",
5+
"outDir": "../dist/esm",
6+
}
7+
}

.config/tsconfig.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
"include": ["../lib/**/*"],
33
"compilerOptions": {
44
"allowJs": true,
5-
"checkJs": true,
6-
"strict": true,
7-
"target": "esnext",
8-
"module": "esnext",
5+
"checkJs": true,
6+
"strict": true,
7+
"target": "ESNext",
8+
"module": "NodeNext",
9+
"moduleResolution": "NodeNext",
910
"noUnusedLocals": true,
1011
"noUnusedParameters": true,
1112
"allowUnreachableCode": false,
1213
"noUncheckedIndexedAccess": true,
13-
1414
"declaration": true,
15-
"declarationDir": "../dist/types",
1615
"isolatedModules": true,
17-
"moduleResolution": "node"
16+
"sourceMap": true,
17+
"rewriteRelativeImportExtensions": true,
1818
},
1919
}

.config/tsconfig.types.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
// This exists for backwards compatibility. In the wild, folks are importing
3+
// paths like `@orchidjs/sifter.js/dist/types/...`.
4+
//
5+
// Consider removing this in the next major version.
6+
"extends": "./tsconfig.json",
7+
"compilerOptions": {
8+
"outDir": "../dist/types",
9+
"emitDeclarationOnly": true
10+
}
11+
}

.github/workflows/ci.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Node.js CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: ['18.x', '20.x', '22.x']
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Use Node.js ${{ matrix.node-version }}
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: ${{ matrix.node-version }}
23+
- run: npm ci
24+
- run: npm run build
25+
- run: npm run test
26+
- run: npm run test:types

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,4 @@
22
node_modules
33
benchmark/report*.json
44
coverage
5-
package-lock.json
6-
build
7-
x-*
85
dist

.travis.yml

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

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"typescript.tsdk": "node_modules/typescript/lib"
3+
}

0 commit comments

Comments
 (0)