Skip to content
Open
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
21 changes: 21 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,27 @@ jobs:
uses: ./.github/actions/build-fabric-cached
- name: Run ${{ matrix.suite }} tests
run: npm run test -- -c node -s ${{ matrix.suite }}
ts:
runs-on: ubuntu-latest
name: TS ${{ matrix.ts }} tests
strategy:
fail-fast: false
matrix:
node-version: [18.x]
ts: [4.x, latest]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: |
npm ci
npm i typescript@${{ matrix.ts }}
- name: Build
run: npm run build -- -f
- name: Run tests
run: npm run test -- -s ts
jest:
name: Jest tests
runs-on: ubuntu-latest
Expand Down
5 changes: 3 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ before_commit
/scripts/cli_cache.json
**/dist/
/lib/
/test/
test/*
!/test/ts
/website/
.next/
.parcel-cache/
/docs/
/e2e/test-results/
/e2e/test-report/
/e2e/tests/**/*-snapshots/*.json
/e2e/tests/**/*-snapshots/*.json
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [next]

- ci(): add TS test suite [#8394](https://github.com/fabricjs/fabric.js/pull/8394)
- chore(): Upgrade Rollup to 4.9.5 [#9613](https://github.com/fabricjs/fabric.js/pull/9613)
- chore(): Upgrade rollup and plugins at latest 3 [#9612](https://github.com/fabricjs/fabric.js/pull/9612)
- fix(WebGLFilterBackend) Destroy the context of queryWebgl test function, remove automatic perf checkup, make it explicit with a function [#8932](https://github.com/fabricjs/fabric.js/pull/8932)
Expand Down
35 changes: 35 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
"busboy": "^1.6.0",
"chalk": "^2.4.1",
"commander": "^9.1.0",
"conditional-type-checks": "^1.0.6",
"eslint": "8.40",
"eslint-config-prettier": "^8.6.0",
"fireworm": "^0.7.2",
Expand All @@ -117,6 +118,7 @@
"prettier": "2.7.1",
"ps-list": "^8.1.0",
"qunit": "^2.17.2",
"rollup-plugin-no-emit": "^1.1.1",
"rollup": "^4.9.5",
"semver": "^7.3.8",
"source-map-support": "^0.5.21",
Expand Down
20 changes: 13 additions & 7 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import ts from '@rollup/plugin-typescript';
import { babel } from '@rollup/plugin-babel';
import path from 'path';
import chalk from 'chalk';
// import dts from "rollup-plugin-dts";
import noEmit from 'rollup-plugin-no-emit';

const splitter = /\n|\s|,/g;

const input = process.env.BUILD_INPUT?.split(splitter) || ['./index.ts'];
const outputType = input.length > 1 ? 'dir' : 'file';
const buildOutput = process.env.BUILD_OUTPUT || './dist/index.js';

const dirname = path.dirname(buildOutput);
Expand All @@ -20,6 +21,7 @@ const plugins = [
tsconfig: './tsconfig.json',
exclude: ['dist', '**/**.spec.ts', '**/**.test.ts'],
}),
noEmit({ emit: !Number(process.env.NO_EMIT) }),
babel({
extensions: ['.ts', '.js'],
babelHelpers: 'bundled',
Expand Down Expand Up @@ -47,14 +49,16 @@ function onwarn(warning, warn) {
}
warn(warning);
}

// https://rollupjs.org/guide/en/#configuration-files
export default [
const config = [
{
input: process.env.BUILD_INPUT?.split(splitter) || ['./index.ts'],
input,
output: [
{
file: path.resolve(dirname, `${basename}.mjs`),
[outputType]:
outputType === 'file'
? path.resolve(dirname, `${basename}.mjs`)
: path.resolve(dirname),
name: 'fabric',
format: 'es',
sourcemap: true,
Expand All @@ -65,7 +69,7 @@ export default [
format: 'umd',
sourcemap: true,
},
Number(process.env.MINIFY)
Number(process.env.MINIFY) && outputType === 'file'
? {
file: path.resolve(dirname, `${basename}.min.js`),
name: 'fabric',
Expand Down Expand Up @@ -98,3 +102,5 @@ export default [
external: ['jsdom', 'jsdom/lib/jsdom/living/generated/utils.js', 'canvas'],
},
];
console.log(config[0].output);
export default config;
32 changes: 25 additions & 7 deletions scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,28 @@ import { wd } from './dirname.mjs';
* @see https://rollupjs.org/guide/en/#--watchonstart-cmd---watchonbundlestart-cmd---watchonbundleend-cmd---watchonend-cmd---watchonerror-cmd
* @param {*} options
*/
export function build({ watch, fast, input, output, stats = false } = {}) {
export function build({
watch,
fast,
input,
output,
report = true,
emit = true,
stats = false,
} = {}) {
const cmd = [
'rollup',
'-c',
watch ? '--watch' : '',
'--no-watch.clearScreen',
...['onStart', 'onError', 'onEnd'].map(
(type) =>
`--watch.${type} "node ./scripts/buildReporter.mjs ${type
.toLowerCase()
.slice(2)}"`
),
...(report
? [('onStart', 'onError', 'onEnd')].map(
(type) =>
`--watch.${type} "node ./scripts/buildReporter.mjs ${type
.toLowerCase()
.slice(2)}"`
)
: []),
].join(' ');
const processOptions = {
stdio: 'inherit',
Expand All @@ -32,6 +42,14 @@ export function build({ watch, fast, input, output, stats = false } = {}) {
MINIFY: Number(!fast),
BUILD_INPUT: Array.isArray(input) ? input.join(' ') : input,
BUILD_OUTPUT: output,
BUILD_MIN_OUTPUT:
output && !Array.isArray(input) && !fast
? path.resolve(
path.dirname(output),
`${path.basename(output, '.js')}.min.js`
)
: undefined,
NO_EMIT: Number(!emit),
BUILD_STATS: Number(stats),
},
};
Expand Down
Loading