Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revamp build #33

Merged
merged 4 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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';
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that tom-select was reaching into dist/types/... to get these; figured it'd be cleaner to export them from the top-level module.

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