@@ -596,6 +596,56 @@ jobs:
596596 - name : Verify generated types are in sync with schema
597597 run : npm run schema-typegen-diff-check
598598
599+ package-resolution :
600+ needs : install-and-cibuild
601+ runs-on : ubuntu-latest
602+ steps :
603+ - uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
604+ - uses : ./.github/actions/setup-workspace
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');
648+
599649 # ============================================================
600650 # Standalone jobs (no dependencies on install-and-cibuild)
601651 # ============================================================
0 commit comments