also looking at this
fix(release): build and verify all npm package artifacts
#289
11 files
+290
-3
Review threads live on the whole diff, not on one commit, so none are shown here - a thread's line means something in the branch's final form, and painting it into an intermediate step would put it on code it is not about.
| @@ -8,6 +8,10 @@ Svelte bindings for the Craft framework using stores and actions. | ||
| 8 | 8 | npm install @craft-native/svelte |
| 9 | 9 | ``` |
| 10 | 10 | |
| 11 | The package includes its TypeScript source for bundlers that select the `svelte` | |
| 12 | export condition. Other consumers use the compiled ESM or CommonJS entry in | |
| 13 | `dist`. Both entries expose the same stores and actions. | |
| 14 | ||
| 11 | 15 | ## Usage |
| 12 | 16 | |
| 13 | 17 | ### Stores |
| @@ -0,0 +1,33 @@ | ||
| 1 | import { expect, test } from 'bun:test' | |
| 2 | import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs' | |
| 3 | import { tmpdir } from 'node:os' | |
| 4 | import { join, resolve } from 'node:path' | |
| 5 | ||
| 6 | test('packed Svelte condition resolves outside the workspace', async () => { | |
| 7 | const root = resolve(import.meta.dir, '..') | |
| 8 | const temp = mkdtempSync(join(tmpdir(), 'craft-svelte-package-')) | |
| 9 | try { | |
| 10 | const packed = Bun.spawnSync([ | |
| 11 | process.execPath, 'pm', 'pack', '--filename', join(temp, 'package.tgz'), | |
| 12 | ], { cwd: join(root, 'packages/svelte'), stdout: 'pipe', stderr: 'pipe' }) | |
| 13 | expect(packed.exitCode).toBe(0) | |
| 14 | const installed = join(temp, 'node_modules/@craft-native/svelte') | |
| 15 | mkdirSync(installed, { recursive: true }) | |
| 16 | const extracted = Bun.spawnSync([ | |
| 17 | 'tar', '-xzf', join(temp, 'package.tgz'), '--strip-components=1', '-C', installed, | |
| 18 | ], { stdout: 'pipe', stderr: 'pipe' }) | |
| 19 | expect(extracted.exitCode).toBe(0) | |
| 20 | writeFileSync(join(temp, 'consumer.ts'), "export * from '@craft-native/svelte'\n") | |
| 21 | const bundled = await Bun.build({ | |
| 22 | entrypoints: [join(temp, 'consumer.ts')], | |
| 23 | conditions: ['svelte'], | |
| 24 | external: ['svelte', 'svelte/*', 'craft-native'], | |
| 25 | target: 'browser', | |
| 26 | }) | |
| 27 | expect(bundled.logs.filter(log => log.level === 'error')).toEqual([]) | |
| 28 | expect(bundled.success).toBe(true) | |
| 29 | } | |
| 30 | finally { | |
| 31 | rmSync(temp, { recursive: true, force: true }) | |
| 32 | } | |
| 33 | }) | |