Skip to content

Commit db7db46

Browse files
author
Guy Bedford
authored
feat: implement the "fastly" condition (#660)
1 parent 3b97363 commit db7db46

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import test from 'brittle';
2+
import { getBinPath } from 'get-bin-path'
3+
import { prepareEnvironment } from '@jakechampion/cli-testing-library';
4+
5+
const cli = await getBinPath()
6+
7+
test('should build the fastly condition', async function (t) {
8+
const { execute, cleanup, writeFile, exists, path } = await prepareEnvironment();
9+
t.teardown(async function () {
10+
await cleanup();
11+
});
12+
13+
await writeFile('./index.js', `import '#test';`)
14+
await writeFile('./test.js', `addEventListener('fetch', function(){})`)
15+
await writeFile('./package.json', `{ "type": "module", "imports": { "#test": { "fastly": "./test.js" } } }`)
16+
17+
t.is(await exists('./app.wasm'), false)
18+
19+
const { code, stdout, stderr } = await execute(process.execPath, `${cli} ${path}/index.js ${path}/app.wasm`);
20+
21+
t.is(await exists('./app.wasm'), true)
22+
t.alike(stdout, []);
23+
t.alike(stderr, []);
24+
t.is(code, 0);
25+
});

src/bundle.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export const allowDynamicBackends = Object.getOwnPropertyDescriptor(globalThis.f
4444

4545
export async function bundle(input) {
4646
return await build({
47+
conditions: ['fastly'],
4748
entryPoints: [input],
4849
bundle: true,
4950
write: false,

0 commit comments

Comments
 (0)