Skip to content

Commit

Permalink
Support for wasm (#5316)
Browse files Browse the repository at this point in the history
* 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())
  • Loading branch information
AndyBitz authored and timneutkens committed Oct 2, 2018
1 parent e994159 commit b041fa4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions packages/next-server/server/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion packages/next/build/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion test/integration/export/pages/dynamic-imports.js
Original file line number Diff line number Diff line change
@@ -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 () => (
<div id='dynamic-imports-page'>
Expand Down

0 comments on commit b041fa4

Please sign in to comment.