Skip to content

Commit

Permalink
Features/watch (#3)
Browse files Browse the repository at this point in the history
* Run in background during watch mode (nonblocking)
Use ESM
Use Parcel

* Fix failing tests
Export compiler function

* lint

* Update readme

* Update dependencies

* Update pipeline

* Fix coverage output

* Add caching
Add matrix testing
Update test triggers

* Increase timeout

* Update version

Co-authored-by: Dominic Birch <[email protected]>
  • Loading branch information
dominicbirch and dominicbirch authored Dec 22, 2022
1 parent f0695e6 commit 3f483fe
Show file tree
Hide file tree
Showing 21 changed files with 8,797 additions and 6,148 deletions.
4 changes: 3 additions & 1 deletion .artifactignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.vscode/
node_modules/
src/
test/
/tsconfig.json
/*.ts
/*.tgz
Expand All @@ -9,4 +10,5 @@ src/
.gitignore
.eslintcache
.eslintrc.*
.github/
.github/
.parcel-cache/
2 changes: 2 additions & 0 deletions .eslintrc.js → .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ module.exports = {
],
ignorePatterns: [
'lib/*.*',
'dist/*.*',
'test/*.*',
],
rules: {},
};
7 changes: 6 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@ jobs:
environment: Production
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: .parcel-cache
key: ${{ runner.os }}-node${{ matrix.node }}-parcel
- uses: actions/setup-node@v3
with:
registry-url: https://registry.npmjs.org/
node-version: 16
node-version: 18
cache: npm
- run: npm ci
- run: npm publish
env:
Expand Down
23 changes: 21 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,34 @@
name: Run tests

on: [push, pull_request]
on:
pull_request:
branches:
- master
push:
branches:
- master

jobs:
test:
name: Run tests
runs-on: ubuntu-latest
strategy:
matrix:
node: [ 16, 17, 18, 19 ]
name: Run tests on Node ${{ matrix.node }}
steps:
- uses: actions/checkout@master
- uses: actions/cache@v3
with:
path: .parcel-cache
key: ${{ runner.os }}-node${{ matrix.node }}-parcel
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: npm
- run: npm ci
- run: npx parcel build --no-source-maps --no-autoinstall
env:
NODE_ENV: production
- run: npm test -- --ci --coverage --json --outputFile=test-results.json --testResultsProcessor="jest-junit"
- name: Code Coverage Summary Report
uses: irongut/[email protected]
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
lib/
test/
dist/
bin/
node_modules/
Expand All @@ -7,4 +8,5 @@ coverage/
yarn.lock
.eslintcache
junit.xml
test-results.json
test-results.json
.parcel-cache
6 changes: 5 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
.vscode/
node_modules/
src/
test/
lib/
/tsconfig.json
/*.ts
/*.tgz
Expand All @@ -11,4 +13,6 @@ coverage/
.eslintrc.*
.github/
junit.xml
test-results.json
test-results.json
.parcel-cache/
webpack.config.*
37 changes: 24 additions & 13 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,10 @@
{
"type": "node",
"request": "launch",
"name": "Debug webpack build",
"presentation": {
"hidden": false,
"group": "Debug",
"order": 1
},
"timeout": 60000,
"name": "Debug",
"sourceMaps": true,
"autoAttachChildProcesses": true,
"stopOnEntry": false,
"disableOptimisticBPs": true,
"skipFiles": [
"<node_internals>/**"
],
Expand All @@ -26,11 +19,29 @@
"NODE_ENV": "production",
"mode": "production"
},
"runtimeExecutable": "yarn",
"runtimeExecutable": "webpack",
"runtimeArgs": [
"run",
"prepack"
]
"--watch",
],
"preLaunchTask": "parcel:watch"
},
]
{
"name": "Test",
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}",
"sourceMaps": true,
"autoAttachChildProcesses": true,
"skipFiles": [
"<node_internals>/**"
],
"runtimeExecutable": "node",
"runtimeArgs": ["--experimental-vm-modules"],
"program": "${workspaceFolder}/node_modules/jest-cli/bin/jest.js",
"args": ["--watchAll"],
"console": "integratedTerminal",
"preLaunchTask": "parcel:watch"
}
],
"compounds": []
}
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
"*.js": "$(capture).*",
"*.json": "$(capture)*.json",
},
"typescript.tsdk": "./node_modules/typescript/lib"
}
46 changes: 46 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"version": "2.0.0",
"inputs": [],
"tasks": [
{
"type": "npm",
"script": "watch",
"label": "parcel:watch",
"detail": "parcel watch",
"isBackground": true,
"problemMatcher": [
{
"owner": "npm",
"pattern": [
{
"regexp": "^.*?@parcel\\S+?:\\s*(.*)$",
"message": 1,

},
{
"regexp": "^.*?(\\S+?):(\\d+):(\\d+)$",
"file": 1,
"line": 2,
"column": 3,
"loop": true,
},
],
"background": {
"activeOnStart": true,
"beginsPattern": "(.*?)",
"endsPattern": "(^.*?Buil(t\\sin\\s\\d+|d\\sfailed))"
}
}
],
"presentation": {
"echo": true,
"focus": true,
"clear": true,
"close": true,
"panel": "dedicated",
"reveal": "always",
"revealProblems": "onProblem",
},
}
]
}
25 changes: 21 additions & 4 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
import type { InitialOptionsTsJest } from "ts-jest";
import type { JestConfigWithTsJest } from "ts-jest";


export default <InitialOptionsTsJest>{
preset: "ts-jest",
export default <JestConfigWithTsJest>{
preset: "ts-jest/presets/default-esm",
testEnvironment: "node",
collectCoverageFrom: ['src/**/*.ts', '!**/*.d.ts'],
coverageDirectory: "coverage",
coverageReporters: [
"cobertura",
"clover",
"lcov",
]
],
moduleDirectories: ['node_modules', 'src'],
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.[tj]s$': '$1',
},
moduleFileExtensions: ["js", "ts"],
extensionsToTreatAsEsm: [".ts"],
transform: {
'\\.ts$': [
'ts-jest',
{
useESM: true,
isolatedModules: true,
tsconfig: "./tsconfig.json",
},
],
},
};
Loading

0 comments on commit 3f483fe

Please sign in to comment.