Skip to content
Merged
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
10 changes: 4 additions & 6 deletions build/build-cjs.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Generate the CommonJS entry point (node-ical.cjs) from the ESM sources.
//
// ESM (*.js, type: module) is the single source of truth. This bundles
// node-ical.js into a single self-contained CommonJS file so that
// `require('node-ical')` keeps working, while runtime dependencies stay
// external `require()` calls.
// node-ical.js into a single CommonJS file so that `require('node-ical')` keeps
// working. The Temporal polyfill is bundled because its v1 package is ESM-only;
// rrule-temporal remains an external runtime dependency.
import {build} from 'esbuild';

await build({
Expand All @@ -14,8 +14,6 @@ await build({
format: 'cjs',
// Keep in sync with engines.node in package.json and node-version in .github/workflows/nodejs.yml
target: 'node22',
// Keep node_modules dependencies as require() calls; only bundle our own code
// (and inline windowsZones.json, which is imported relatively).
packages: 'external',
external: ['rrule-temporal', 'rrule-temporal/totext'],
logLevel: 'info',
});
47 changes: 36 additions & 11 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
},
"dependencies": {
"rrule-temporal": "^2.0.0",
"temporal-polyfill": "^0.3.2"
"temporal-polyfill": "^1.0.1"
},
"devDependencies": {
"date-fns": "^4.4.0",
Expand Down
17 changes: 17 additions & 0 deletions test/polyfill-check.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import assert from 'node:assert/strict';
import {execSync} from 'node:child_process';
import {readFileSync} from 'node:fs';
import {describe, it} from 'mocha';

describe('Temporal Polyfill Configuration', () => {
Expand All @@ -12,4 +13,20 @@ describe('Temporal Polyfill Configuration', () => {
assert.ok(true, 'JSBI is not installed as expected');
}
});

it('should use temporal-polyfill v1 as a direct dependency', () => {
// Read the installed package's own package.json directly instead of
// shelling out to `npm ls`, which can exit non-zero (and make execSync
// throw) for unrelated dependency-tree issues.
const packageJsonUrl = new URL('../node_modules/temporal-polyfill/package.json', import.meta.url);
const {version} = JSON.parse(readFileSync(packageJsonUrl, 'utf8'));

assert.match(String(version), /^1\./v);
});

it('should load temporal-polyfill via ESM import', async () => {
const mod = await import('temporal-polyfill');

assert.ok(mod.Temporal, 'temporal-polyfill should expose Temporal');
});
});