Skip to content

Commit d0454f7

Browse files
committed
Perform resolve test in CI
1 parent c1d910f commit d0454f7

1 file changed

Lines changed: 43 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,8 +602,49 @@ jobs:
602602
steps:
603603
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
604604
- uses: ./.github/actions/setup-workspace
605-
- name: Verify the published package loads under Node
606-
run: npm run test-node-resolve
605+
606+
- name: Pack the package
607+
run: npm pack --pack-destination "$RUNNER_TEMP"
608+
609+
- name: Install the tarball into a scratch project
610+
working-directory: ${{ runner.temp }}
611+
run: |
612+
mkdir consumer && cd consumer
613+
npm init -y
614+
npm install "$RUNNER_TEMP"/plotly.js-*.tgz
615+
616+
- name: Load every compiled module under Node
617+
shell: node {0}
618+
working-directory: ${{ runner.temp }}/consumer
619+
run: |
620+
const assert = require('node:assert');
621+
const fs = require('node:fs');
622+
623+
// src/lib/index.js reaches for these before it touches the DOM.
624+
globalThis.self = globalThis;
625+
globalThis.window = globalThis;
626+
627+
const paths = [process.cwd()];
628+
const load = (name) => require(require.resolve(name, { paths }));
629+
630+
const modules = fs
631+
.globSync('src/**/*.ts', { cwd: process.env.GITHUB_WORKSPACE })
632+
.filter((file) => !file.endsWith('.d.ts'))
633+
.map((file) => 'plotly.js/' + file.replace(/[.]ts$/, ''));
634+
635+
if (modules.length === 0) throw new Error('Found no TypeScript sources to check');
636+
637+
for (const name of modules) load(name);
638+
639+
const lib = load('plotly.js/src/lib/index');
640+
641+
assert.strictEqual(lib.mod(-1, 4), 3);
642+
assert.strictEqual(lib.modHalf(3, 4), -1);
643+
assert.deepStrictEqual(lib.sortObjectKeys({ b: 1, a: 2 }), ['a', 'b']);
644+
assert.strictEqual(lib.cleanNumber(' 12 '), 12);
645+
assert.strictEqual(typeof lib.counterRegex, 'function');
646+
647+
console.log('Loaded ' + modules.length + ' compiled modules and src/lib/index.js');
607648
608649
# ============================================================
609650
# Standalone jobs (no dependencies on install-and-cibuild)

0 commit comments

Comments
 (0)