Skip to content

Commit

Permalink
Merge 2439d79 into bf18538
Browse files Browse the repository at this point in the history
  • Loading branch information
dangreen committed Oct 11, 2022
2 parents bf18538 + 2439d79 commit f3cb135
Show file tree
Hide file tree
Showing 6 changed files with 286 additions and 110 deletions.
30 changes: 3 additions & 27 deletions .github/workflows/ci.yml
Expand Up @@ -3,17 +3,16 @@ on:
push:
pull_request:
jobs:
base-test:
test:
runs-on: ubuntu-latest
name: Node.js base test
if: "!contains(github.event.head_commit.message, '[ci skip]')"
name: Node.js test
steps:
- name: Checkout the repository
uses: actions/checkout@v2
- name: Install Node.js
uses: actions/setup-node@v2
with:
node-version: 12
node-version: 14
- name: Install dependencies
uses: bahmutov/npm-install@v1
- name: Run tests
Expand All @@ -23,26 +22,3 @@ jobs:
if: success()
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
matrix-test:
strategy:
matrix:
node-version:
- 12
- 14
runs-on:
- ubuntu-latest
- macos-latest
name: Node.js ${{ matrix.node-version }} on ${{ matrix.runs-on }} matrix test
runs-on: ${{ matrix.runs-on }}
if: "!contains(github.event.head_commit.message, '[ci skip]')"
steps:
- name: Checkout the repository
uses: actions/checkout@v2
- name: Install Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
uses: bahmutov/npm-install@v1
- name: Run tests
run: yarn test
8 changes: 7 additions & 1 deletion jest.config.json
Expand Up @@ -2,7 +2,13 @@
"testEnvironment": "node",
"testRegex": "/src/.*\\.spec\\.(jsx?|tsx?)$",
"transform": {
"^.+\\.(jsx?|tsx?)$": "babel-jest"
"^.+\\.(t|j)sx?$": ["@swc/jest", {
"env": {
"targets": {
"node": 12
}
}
}]
},
"collectCoverage": true,
"collectCoverageFrom": [
Expand Down
15 changes: 10 additions & 5 deletions package.json
Expand Up @@ -20,14 +20,15 @@
"node": ">=12.0.0"
},
"scripts": {
"emitDeclarations": "tsc --emitDeclarationOnly",
"build": "rollup -c && yarn emitDeclarations",
"lint": "trigen-scripts lint",
"jest": "trigen-scripts jest",
"jest": "jest -c jest.config.json",
"checkSize": "trigen-scripts checkSize",
"test": "trigen-scripts test",
"build:demo": "node examples/buildDemo > ./docs/demo.html && cp -R examples/demojs/ docs/demojs/",
"build:docs": "trigen-scripts build:docs",
"start": "trigen-scripts start",
"build": "trigen-scripts build",
"cleanPublish": "trigen-scripts test && del 'lib/**/*.spec.*' && clean-publish"
},
"keywords": [
Expand All @@ -44,8 +45,12 @@
},
"devDependencies": {
"@babel/core": "^7.12.10",
"@rollup/plugin-eslint": "^8.0.1",
"@rollup/plugin-node-resolve": "^15.0.0",
"@size-limit/preset-small-lib": "^5.0.4",
"@swc/core": "^1.3.6",
"@swc/helpers": "^0.4.12",
"@swc/jest": "^0.2.23",
"@trigen/browserslist-config": "^8.0.0-alpha.5",
"@trigen/eslint-config": "^7.3.4",
"@trigen/scripts": "^7.3.1",
"@trigen/scripts-plugin-babel": "^7.3.1",
Expand All @@ -58,9 +63,9 @@
"browserslist-useragent": "^3.0.0",
"del-cli": "^4.0.1",
"eslint": "7.18.0",
"rollup": "^2.38.4",
"rollup": "^2.79.1",
"rollup-plugin-add-shebang": "^0.3.0",
"rollup-plugin-typescript2": "^0.30.0",
"rollup-plugin-swc": "^0.2.1",
"size-limit": "^5.0.4",
"typescript": "^4.1.3",
"user-agents": "^1.0.213"
Expand Down
56 changes: 28 additions & 28 deletions rollup.config.js
@@ -1,55 +1,55 @@
import swc from 'rollup-plugin-swc';
import {
external
} from '@trigen/scripts-plugin-rollup/helpers';
import eslint from '@rollup/plugin-eslint';
import commonjs from '@rollup/plugin-commonjs';
import typescript from 'rollup-plugin-typescript2';
import babel from '@rollup/plugin-babel';
nodeResolve
} from '@rollup/plugin-node-resolve';
import nodeEsm from '@trigen/browserslist-config/node-esm';
import shebang from 'rollup-plugin-add-shebang';
import {
DEFAULT_EXTENSIONS
} from '@babel/core';
import pkg from './package.json';

const plugins = [
eslint({
exclude: ['**/*.json', 'node_modules/**'],
throwOnError: true
const extensions = ['.js', '.ts'];
const external = _ => /node_modules/.test(_) && !/@swc\/helpers/.test(_);
const plugins = targets => [
nodeResolve({
extensions
}),
commonjs(),
typescript(),
babel({
extensions: [
...DEFAULT_EXTENSIONS,
'ts',
'tsx'
],
babelHelpers: 'runtime',
skipPreflightCheck: true
swc({
jsc: {
parser: {
syntax: 'typescript'
},
externalHelpers: true
},
env: {
targets
},
module: {
type: 'es6'
},
sourceMaps: true
})
];

export default [{
input: 'src/index.ts',
plugins,
external: external(pkg, true),
plugins: plugins(nodeEsm.join(', ')),
external,
output: {
file: pkg.main,
format: 'cjs',
exports: 'named',
sourcemap: 'inline'
sourcemap: true
}
}, {
input: 'src/cli.ts',
plugins: [
...plugins,
...plugins(nodeEsm.join(', ')),
shebang()
],
external: _ => !_.endsWith('src/cli.ts'),
output: {
file: 'lib/cli.js',
format: 'cjs',
exports: 'named',
sourcemap: 'inline'
sourcemap: true
}
}];
3 changes: 2 additions & 1 deletion tsconfig.json
Expand Up @@ -18,7 +18,8 @@
"baseUrl": ".",
"lib": [
"esnext"
]
],
"outDir": "lib"
},
"include": [
"src/**/*.ts"
Expand Down

0 comments on commit f3cb135

Please sign in to comment.