Skip to content

Commit

Permalink
Revamp build (#33)
Browse files Browse the repository at this point in the history
* WIP build revamp

* Refine types; add GitHub Actions workflow

* Export types

* Upgrade @orchidjs/unicode-variants
  • Loading branch information
nwalters512 authored Nov 15, 2024
1 parent edaf386 commit af33064
Show file tree
Hide file tree
Showing 15 changed files with 6,396 additions and 80 deletions.
11 changes: 4 additions & 7 deletions .config/babel.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
[
"@babel/preset-env",
{
loose: true,
bugfixes: true,
modules: false
"loose": true,
"bugfixes": true,
"modules": false
}
],
"@babel/typescript"
],
"plugins": [
["@babel/plugin-proposal-class-properties", { "loose": true }]
]
]
}
34 changes: 5 additions & 29 deletions .config/rollup.config.js → .config/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import babel from '@rollup/plugin-babel';
import { terser } from 'rollup-plugin-terser';
import terser from '@rollup/plugin-terser';
import resolve from '@rollup/plugin-node-resolve'; // so Rollup can resolve imports without file extensions and `node_modules`
import path from 'path';
import { fileURLToPath } from 'url';

var configs = [];
const __dirname = path.dirname(fileURLToPath(import.meta.url));

const configs = [];
const banner = `/*! sifter.js | https://github.com/orchidjs/sifter.js | Apache License (v2) */`;

const extensions = [
Expand Down Expand Up @@ -36,33 +39,6 @@ var terser_config = terser({
});


// esm
configs.push({
input: path.resolve(__dirname,'../lib/sifter.ts'),
output:{
dir: path.resolve(__dirname,'../dist/esm'),
format: 'esm',
preserveModules: true,
sourcemap: true,
banner: banner,
},
plugins:[babel_config,resolve_config]
});

// cjs
configs.push({
input: path.resolve(__dirname,'../lib/sifter.ts'),
output:{
dir: path.resolve(__dirname,'../dist/cjs'),
format: 'cjs',
preserveModules: false,
sourcemap: true,
banner: banner,
},
plugins:[babel_config,resolve_config]
});


// umd
configs.push({
input: path.resolve(__dirname,'../lib/sifter.ts'),
Expand Down
8 changes: 8 additions & 0 deletions .config/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "CommonJS",
"moduleResolution": "Node",
"outDir": "../dist/cjs",
}
}
7 changes: 7 additions & 0 deletions .config/tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "NodeNext",
"outDir": "../dist/esm",
}
}
14 changes: 7 additions & 7 deletions .config/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
"include": ["../lib/**/*"],
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"strict": true,
"target": "esnext",
"module": "esnext",
"checkJs": true,
"strict": true,
"target": "ESNext",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"noUnusedLocals": true,
"noUnusedParameters": true,
"allowUnreachableCode": false,
"noUncheckedIndexedAccess": true,

"declaration": true,
"declarationDir": "../dist/types",
"isolatedModules": true,
"moduleResolution": "node"
"sourceMap": true,
"rewriteRelativeImportExtensions": true,
},
}
11 changes: 11 additions & 0 deletions .config/tsconfig.types.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
// This exists for backwards compatibility. In the wild, folks are importing
// paths like `@orchidjs/sifter.js/dist/types/...`.
//
// Consider removing this in the next major version.
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../dist/types",
"emitDeclarationOnly": true
}
}
26 changes: 26 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Node.js CI

on:
push:
branches:
- main
pull_request:

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: ['18.x', '20.x', '22.x']

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build
- run: npm run test
- run: npm run test:types
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@
node_modules
benchmark/report*.json
coverage
package-lock.json
build
x-*
dist
10 changes: 0 additions & 10 deletions .travis.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typescript.tsdk": "node_modules/typescript/lib"
}
5 changes: 3 additions & 2 deletions lib/sifter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
* @author Brian Reavis <[email protected]>
*/

import { scoreValue, getAttr, getAttrNesting, propToArray, iterate, cmp } from './utils';
import { scoreValue, getAttr, getAttrNesting, propToArray, iterate, cmp } from './utils.ts';
import { getPattern, escape_regex } from '@orchidjs/unicode-variants';
import * as T from './types';
import * as T from './types.ts';

class Sifter{

Expand Down Expand Up @@ -353,3 +353,4 @@ class Sifter{
}

export { Sifter, scoreValue, getAttr, getAttrNesting, propToArray, iterate, cmp, getPattern }
export * from './types.ts';
2 changes: 1 addition & 1 deletion lib/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import {Sifter} from './sifter';
import {Sifter} from './sifter.ts';

export type Field = {
field: string,
Expand Down
2 changes: 1 addition & 1 deletion lib/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

import { asciifold } from '@orchidjs/unicode-variants';
import * as T from './types';
import * as T from './types.ts';


/**
Expand Down
Loading

0 comments on commit af33064

Please sign in to comment.