Skip to content

Commit e96ea3a

Browse files
committed
Merge branch 'main' into route-params-possibility
2 parents 1601039 + 41bbf06 commit e96ea3a

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"types": "./index.d.ts",
88
"type": "module",
99
"scripts": {
10+
"test-build": "node --experimental-modules test/bundle-using-wmr.js",
1011
"test": "node --experimental-vm-modules node_modules/.bin/jest"
1112
},
1213
"exports": {

test/bundle-using-wmr.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { mkdirSync, rmdirSync, unlinkSync, readdirSync, renameSync, writeFileSync } from 'fs';
2+
import { execFileSync } from 'child_process';
3+
4+
const code = `
5+
import 'preact';
6+
import 'preact/hooks';
7+
import 'preact-render-to-string';
8+
import('../index.js');
9+
`;
10+
11+
rmr('.dist');
12+
rmr('.tmp');
13+
mkdirSync('.tmp');
14+
writeFileSync('.tmp/x.js', code);
15+
writeFileSync('.tmp/index.html', '<script type=module src=x.js>');
16+
execFileSync('node', ['--experimental-modules', '../../wmr/src/cli.js', 'build'], {
17+
cwd: '.tmp',
18+
encoding: 'utf-8',
19+
stdio: 'inherit'
20+
});
21+
renameSync('.tmp/dist/chunks', '.dist');
22+
rmr('.tmp');
23+
24+
function rmr(path) {
25+
try {
26+
readdirSync(path).forEach(rmr);
27+
rmdirSync(path, { recursive: true });
28+
} catch (e) {
29+
try {
30+
unlinkSync(path);
31+
} catch (e) {}
32+
}
33+
}

0 commit comments

Comments
 (0)