Skip to content

Commit

Permalink
Rework transpile and bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
lahmatiy committed Jun 17, 2024
1 parent 12e669c commit 37b7100
Show file tree
Hide file tree
Showing 10 changed files with 843 additions and 849 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
pull_request:

env:
PRIMARY_NODEJS_VERSION: 16
PRIMARY_NODEJS_VERSION: 20
REPORTER: "min"

jobs:
Expand All @@ -28,8 +28,7 @@ jobs:
strategy:
matrix:
node_version:
- 10
- 16
- 20
steps:
- uses: actions/checkout@v2
- name: Setup node ${{ matrix.node_version }}
Expand Down Expand Up @@ -68,7 +67,7 @@ jobs:
node-version: ${{ env.PRIMARY_NODEJS_VERSION }}
cache: "npm"
- run: npm ci
- run: npm run build-and-test
- run: npm run bundle-and-test

unit-tests:
name: Unit tests
Expand All @@ -81,6 +80,8 @@ jobs:
- 12.20.0
- 14.13.0
- 16
- 20
- 22

steps:
- uses: actions/checkout@v2
Expand All @@ -90,4 +91,6 @@ jobs:
node-version: ${{ matrix.node_version }}
cache: "npm"
- run: npm ci
- run: npm run transpile
- run: npm run test
- run: npm run test:cjs
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
/coverage/
/.nyc_output/
/.vscode/
/cjs/
/cjs-test/
4 changes: 3 additions & 1 deletion dist/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
*
*.js
!.gitignore
!.npmignore
!test/json-ext.js
!test/json-ext.min.js
28 changes: 28 additions & 0 deletions dist/test/json-ext.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* global jsonExt */
import fs from 'node:fs';
import assert from 'node:assert';

describe('dist/json-ext.js', () => {
before(() => new Function(fs.readFileSync('dist/json-ext.js'))());

it('stringifyChunked', () => {
const expected = '{"test":"ok"}';
const actual = [...jsonExt.stringifyChunked({ test: 'ok' })].join('');

assert.strictEqual(actual, expected);
});

it('stringifyInfo', () => {
const expected = '{"test":"ok"}'.length;
const { minLength: actual } = jsonExt.stringifyInfo({ test: 'ok' });

assert.strictEqual(actual, expected);
});

it('parseChunked', async () => {
const expected = { test: 'ok' };
const actual = await jsonExt.parseChunked(() => ['{"test"', ':"ok"}']);

assert.deepStrictEqual(actual, expected);
});
});
28 changes: 28 additions & 0 deletions dist/test/json-ext.min.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* global jsonExt */
import fs from 'node:fs';
import assert from 'node:assert';

describe('dist/json-ext.min.js', () => {
before(() => new Function(fs.readFileSync('dist/json-ext.min.js'))());

it('stringifyChunked', () => {
const expected = '{"test":"ok"}';
const actual = [...jsonExt.stringifyChunked({ test: 'ok' })].join('');

assert.strictEqual(actual, expected);
});

it('stringifyInfo', () => {
const expected = '{"test":"ok"}'.length;
const { minLength: actual } = jsonExt.stringifyInfo({ test: 'ok' });

assert.strictEqual(actual, expected);
});

it('parseChunked', async () => {
const expected = { test: 'ok' };
const actual = await jsonExt.parseChunked(() => ['{"test"', ':"ok"}']);

assert.deepStrictEqual(actual, expected);
});
});
Loading

0 comments on commit 37b7100

Please sign in to comment.