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
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"description": "The lightest signal library.",
"packageManager": "pnpm@9.12.0",
"types": "./types/index.d.ts",
"main": "./cjs/index.cjs",
"module": "./esm/index.mjs",
"exports": {
".": {
"types": "./types/index.d.ts",
Expand Down
19 changes: 19 additions & 0 deletions tests/build.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { existsSync } from 'node:fs';
import { expect } from 'vitest';
import { test } from 'vitest';

Expand All @@ -18,3 +19,21 @@ test('build: esm', async () => {
expect(typeof index.getActiveSub).toBe('function');
expect(typeof system.createReactiveSystem).toBe('function');
});

test('build: entry fields', () => {
const pkg = require('../package.json');
const root = new URL('../', import.meta.url);

// Resolvers that predate `exports`, such as webpack 4, only see these.
expect(pkg.main).toBe('./cjs/index.cjs');
expect(pkg.module).toBe('./esm/index.mjs');

const entries: string[] = [pkg.main, pkg.module, pkg.types];
for (const conditions of Object.values(pkg.exports)) {
entries.push(...Object.values(conditions as Record<string, string>));
}

for (const entry of entries) {
expect(existsSync(new URL(entry, root)), entry).toBe(true);
}
});