From b041fa47829d2ed010665923935c41ce3a4f9fba Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 2 Oct 2018 13:10:07 +0200 Subject: [PATCH] Support for wasm (#5316) * Set a default path for wasm modules * Added the mimetype "application/wasm" for wasm files * Upgrade write-file-webpack-plugin to 4.4.1 * Made dynamic(import()) in test to dynamic(() => import()) --- packages/next-server/server/render.js | 3 +++ packages/next/build/webpack.js | 3 ++- test/integration/export/pages/dynamic-imports.js | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/next-server/server/render.js b/packages/next-server/server/render.js index 98d5d406b9c08..cbee517a9e8ad 100644 --- a/packages/next-server/server/render.js +++ b/packages/next-server/server/render.js @@ -26,6 +26,9 @@ function getDynamicImportBundles (manifest, moduleIds) { const logger = console +// since send doesn't support wasm yet +send.mime.define({ 'application/wasm': ['wasm'] }) + export async function render (req, res, pathname, query, opts) { const html = await renderToHTML(req, res, pathname, query, opts) sendHTML(req, res, html, req.method, opts) diff --git a/packages/next/build/webpack.js b/packages/next/build/webpack.js index d7c85323ff074..fb871e55f7057 100644 --- a/packages/next/build/webpack.js +++ b/packages/next/build/webpack.js @@ -197,7 +197,8 @@ export default async function getBaseWebpackConfig (dir: string, {dev = false, i hotUpdateMainFilename: 'static/webpack/[hash].hot-update.json', // This saves chunks with the name given via `import()` chunkFilename: isServer ? `${dev ? '[name]' : '[name].[contenthash]'}.js` : `static/chunks/${dev ? '[name]' : '[name].[contenthash]'}.js`, - strictModuleExceptionHandling: true + strictModuleExceptionHandling: true, + webassemblyModuleFilename: 'static/wasm/[modulehash].wasm' }, performance: { hints: false }, resolve: resolveConfig, diff --git a/test/integration/export/pages/dynamic-imports.js b/test/integration/export/pages/dynamic-imports.js index 71a8351999590..b1eef236fa54c 100644 --- a/test/integration/export/pages/dynamic-imports.js +++ b/test/integration/export/pages/dynamic-imports.js @@ -1,7 +1,7 @@ import Link from 'next/link' import dynamic from 'next/dynamic' -const DynamicComponent = dynamic(import('../components/hello')) +const DynamicComponent = dynamic(() => import('../components/hello')) export default () => (