Merge pull request #204 from nolanlawson/ignore-source-maps

Add support for sourcemap *.map files
This commit is contained in:
Rich Harris
2018-03-18 21:23:26 -04:00
committed by GitHub
3 changed files with 13 additions and 2 deletions

View File

@@ -25,6 +25,10 @@ export async function exporter(export_dir: string, { basepath = '' }) {
sander.copyFileSync(build_dir, 'service-worker.js').to(export_dir, 'service-worker.js'); sander.copyFileSync(build_dir, 'service-worker.js').to(export_dir, 'service-worker.js');
} }
if (sander.existsSync(build_dir, 'service-worker.js.map')) {
sander.copyFileSync(build_dir, 'service-worker.js.map').to(export_dir, 'service-worker.js.map');
}
const port = await ports.find(3000); const port = await ports.find(3000);
const origin = `http://localhost:${port}`; const origin = `http://localhost:${port}`;

View File

@@ -80,6 +80,11 @@ export default function middleware({ routes, store }: {
cache_control: 'max-age=600' cache_control: 'max-age=600'
}), }),
fs.existsSync(path.join(output, 'service-worker.js.map')) && serve({
pathname: '/service-worker.js.map',
cache_control: 'max-age=600'
}),
serve({ serve({
prefix: '/client/', prefix: '/client/',
cache_control: 'max-age=31536000' cache_control: 'max-age=31536000'
@@ -147,6 +152,7 @@ function get_route_handler(chunks: Record<string, string>, routes: RouteObject[]
// TODO detect other stuff we can preload? images, CSS, fonts? // TODO detect other stuff we can preload? images, CSS, fonts?
const link = [] const link = []
.concat(chunks.main, chunks[route.id]) .concat(chunks.main, chunks[route.id])
.filter(file => !file.match(/\.map$/))
.map(file => `<${req.baseUrl}/client/${file}>;rel="preload";as="script"`) .map(file => `<${req.baseUrl}/client/${file}>;rel="preload";as="script"`)
.join(', '); .join(', ');
@@ -231,6 +237,7 @@ function get_route_handler(chunks: Record<string, string>, routes: RouteObject[]
let scripts = [] let scripts = []
.concat(chunks.main) // chunks main might be an array. it might not! thanks, webpack .concat(chunks.main) // chunks main might be an array. it might not! thanks, webpack
.filter(file => !file.match(/\.map$/))
.map(file => `<script src='${req.baseUrl}/client/${file}'></script>`) .map(file => `<script src='${req.baseUrl}/client/${file}'></script>`)
.join(''); .join('');
@@ -406,4 +413,4 @@ function try_serialize(data: any) {
} catch (err) { } catch (err) {
return null; return null;
} }
} }

View File

@@ -29,7 +29,7 @@ application/java-archive jar
application/java-serialized-object ser application/java-serialized-object ser
application/java-vm class application/java-vm class
application/javascript js application/javascript js
application/json json application/json json map
application/jsonml+json jsonml application/jsonml+json jsonml
application/lost+xml lostxml application/lost+xml lostxml
application/mac-binhex40 hqx application/mac-binhex40 hqx