Skip to content

Commit 43b943c

Browse files
committed
gah have to update the import in dist to use the esm build :/
1 parent 42b7f4b commit 43b943c

7 files changed

Lines changed: 18 additions & 7 deletions

File tree

build.config.mjs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as esbuild from 'esbuild'
2-
import { cpSync, mkdirSync, readdirSync } from 'fs'
2+
import { cpSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from 'fs'
3+
import { join } from 'path'
34
import { execSync } from 'child_process'
45

56
const dev = process.argv.includes('--watch')
@@ -100,6 +101,16 @@ function brotliCompress() {
100101
function copyPlatformScripts() {
101102
mkdirSync(`${OUT}/platform`, { recursive: true })
102103
cpSync('src/platform', `${OUT}/platform`, { recursive: true })
104+
// In src/, `../_hyperscript.js` resolves to the ESM source entry.
105+
// In dist/, the equivalent ESM bundle is `_hyperscript.esm.js` — `_hyperscript.js`
106+
// is the IIFE build and has no exports. Rewrite the import path on copy.
107+
for (const name of readdirSync(`${OUT}/platform`)) {
108+
if (!name.endsWith('.js')) continue
109+
const p = join(OUT, 'platform', name)
110+
const src = readFileSync(p, 'utf8')
111+
const fixed = src.replaceAll("'../_hyperscript.js'", "'../_hyperscript.esm.js'")
112+
if (fixed !== src) writeFileSync(p, fixed)
113+
}
103114
}
104115

105116
if (dev) {

dist/platform/bun-hyperscript.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bun
22

3-
import _hyperscript from '../_hyperscript.js';
3+
import _hyperscript from '../_hyperscript.esm.js';
44
import path from 'node:path';
55

66
const hsExt = '._hs';

dist/platform/deno-hyperscript.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import _hyperscript from '../_hyperscript.js';
1+
import _hyperscript from '../_hyperscript.esm.js';
22
import * as path from 'jsr:@std/path';
33

44
const hsExt = '._hs';

dist/platform/node-hyperscript.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env node
22

3-
import _hyperscript from '../_hyperscript.js';
3+
import _hyperscript from '../_hyperscript.esm.js';
44
import fs from 'node:fs';
55
import path from 'node:path';
66
import { createRequire } from 'node:module';

www/js/platform/bun-hyperscript.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bun
22

3-
import _hyperscript from '../_hyperscript.js';
3+
import _hyperscript from '../_hyperscript.esm.js';
44
import path from 'node:path';
55

66
const hsExt = '._hs';

www/js/platform/deno-hyperscript.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import _hyperscript from '../_hyperscript.js';
1+
import _hyperscript from '../_hyperscript.esm.js';
22
import * as path from 'jsr:@std/path';
33

44
const hsExt = '._hs';

www/js/platform/node-hyperscript.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env node
22

3-
import _hyperscript from '../_hyperscript.js';
3+
import _hyperscript from '../_hyperscript.esm.js';
44
import fs from 'node:fs';
55
import path from 'node:path';
66
import { createRequire } from 'node:module';

0 commit comments

Comments
 (0)