Merge pull request #632 from pngwn/master

Add support for custom route file extensions.
This commit is contained in:
Rich Harris
2019-05-20 22:33:56 -04:00
committed by GitHub
24 changed files with 346 additions and 16 deletions

View File

@@ -19,6 +19,7 @@ type Opts = {
static?: string;
legacy?: boolean;
bundler?: 'rollup' | 'webpack';
ext?: string;
oncompile?: ({ type, result }: { type: string, result: CompileResult }) => void;
};
@@ -32,6 +33,7 @@ export async function build({
bundler,
legacy = false,
ext,
oncompile = noop
}: Opts = {}) {
bundler = validate_bundler(bundler);
@@ -68,7 +70,7 @@ export async function build({
fs.writeFileSync(`${dest}/template.html`, minify_html(template));
const manifest_data = create_manifest_data(routes);
const manifest_data = create_manifest_data(routes, ext);
// create src/node_modules/@sapper/app.mjs and server.mjs
create_app({

View File

@@ -28,7 +28,8 @@ type Opts = {
hot?: boolean,
'devtools-port'?: number,
bundler?: 'rollup' | 'webpack',
port?: number
port?: number,
ext: string
};
export function dev(opts: Opts) {
@@ -47,7 +48,7 @@ class Watcher extends EventEmitter {
}
port: number;
closed: boolean;
dev_port: number;
live: boolean;
hot: boolean;
@@ -67,6 +68,7 @@ class Watcher extends EventEmitter {
unique_warnings: Set<string>;
unique_errors: Set<string>;
}
ext: string;
constructor({
cwd = '.',
@@ -80,7 +82,8 @@ class Watcher extends EventEmitter {
hot,
'devtools-port': devtools_port,
bundler,
port = +process.env.PORT
port = +process.env.PORT,
ext
}: Opts) {
super();
@@ -95,7 +98,7 @@ class Watcher extends EventEmitter {
output: path.resolve(cwd, output),
static: path.resolve(cwd, static_files)
};
this.ext = ext;
this.port = port;
this.closed = false;
@@ -161,7 +164,7 @@ class Watcher extends EventEmitter {
let manifest_data: ManifestData;
try {
manifest_data = create_manifest_data(routes);
manifest_data = create_manifest_data(routes, this.ext);
create_app({
bundler: this.bundler,
manifest_data,
@@ -189,7 +192,7 @@ class Watcher extends EventEmitter {
},
() => {
try {
const new_manifest_data = create_manifest_data(routes);
const new_manifest_data = create_manifest_data(routes, this.ext);
create_app({
bundler: this.bundler,
manifest_data, // TODO is this right? not new_manifest_data?