Skip to content

Commit

Permalink
feat: implement the "fastly" condition (#660)
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Sep 19, 2023
1 parent 3b97363 commit db7db46
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
25 changes: 25 additions & 0 deletions integration-tests/cli/build-config.test.js
@@ -0,0 +1,25 @@
import test from 'brittle';
import { getBinPath } from 'get-bin-path'
import { prepareEnvironment } from '@jakechampion/cli-testing-library';

const cli = await getBinPath()

test('should build the fastly condition', async function (t) {
const { execute, cleanup, writeFile, exists, path } = await prepareEnvironment();
t.teardown(async function () {
await cleanup();
});

await writeFile('./index.js', `import '#test';`)
await writeFile('./test.js', `addEventListener('fetch', function(){})`)
await writeFile('./package.json', `{ "type": "module", "imports": { "#test": { "fastly": "./test.js" } } }`)

t.is(await exists('./app.wasm'), false)

const { code, stdout, stderr } = await execute(process.execPath, `${cli} ${path}/index.js ${path}/app.wasm`);

t.is(await exists('./app.wasm'), true)
t.alike(stdout, []);
t.alike(stderr, []);
t.is(code, 0);
});
1 change: 1 addition & 0 deletions src/bundle.js
Expand Up @@ -44,6 +44,7 @@ export const allowDynamicBackends = Object.getOwnPropertyDescriptor(globalThis.f

export async function bundle(input) {
return await build({
conditions: ['fastly'],
entryPoints: [input],
bundle: true,
write: false,
Expand Down

0 comments on commit db7db46

Please sign in to comment.