Improve internal API

This commit is contained in:
Rich Harris
2018-10-08 19:21:15 -04:00
committed by GitHub
parent 5e59855a15
commit 52f40f9e63
46 changed files with 696 additions and 1091 deletions

View File

@@ -1,4 +1,3 @@
import * as path from 'path';
import * as assert from 'assert';
import * as puppeteer from 'puppeteer';
import { build } from '../../../api';
@@ -17,34 +16,11 @@ describe('encoding', function() {
let prefetchRoutes: () => Promise<void>;
// hooks
before(() => {
return new Promise((fulfil, reject) => {
// TODO this is brittle. Make it unnecessary
process.chdir(__dirname);
process.env.NODE_ENV = 'production';
before(async () => {
await build({ cwd: __dirname });
// TODO this API isn't great. Rethink it
const emitter = build({
bundler: 'rollup'
}, {
src: path.join(__dirname, 'src'),
routes: path.join(__dirname, 'src/routes'),
dest: path.join(__dirname, '__sapper__/build')
});
emitter.on('error', reject);
emitter.on('done', async () => {
try {
runner = new AppRunner(__dirname, '__sapper__/build/server/server.js');
({ base, page, start, prefetchRoutes } = await runner.start());
fulfil();
} catch (err) {
reject(err);
}
});
});
runner = new AppRunner(__dirname, '__sapper__/build/server/server.js');
({ base, page, start, prefetchRoutes } = await runner.start());
});
after(() => runner.end());