Open iSuslov opened 7 months ago
This configuration allows dev server to run:
import { WebWorkerPlugin } from "@shopify/web-worker/webpack";
/** @type {import('next').NextConfig} */
const nextConfig = {
webpack: (config, { isServer, nextRuntime, dev }) => {
if (!isServer) {
config.plugins.push(
new WebWorkerPlugin({
globalObject: "self",
}),
);
config.module.rules.push({
test: /\.(ts|tsx)/,
exclude: /node_modules/,
use: [{
loader: 'babel-loader',
options: {
babelrc: false,
plugins: ['@shopify/web-worker/babel'],
presets: ["@babel/preset-typescript"]
}
}]
})
}
}
}
export default nextConfig
But build still fails:
TypeError: finalInputFileSystem._writeVirtualFile is not a function at VirtualModulesPlugin.writeModule (/Users/user/Projects/p/node_modules/webpack-virtual-modules/lib/index.js:155:30) at Object.pitch (/Users/user/Projects/p/node_modules/@shopify/web-worker/build/cjs/webpack-parts/loader.js:88:29)
Overview
web-worker doesn't work with typescript and nextjs. Suggested
babel-loader
only works with js files. Nextjs uses webpack5 and bunch of own loaders. Addingis not enough.
I was able to make it work by modifying webpack config in
next.config
like this:So the appropriate rule looks like this:
But this solution feels flakey.
Consuming repo
https://github.com/Shopify/quilt/tree/main/packages/web-worker
Scope
Is this issue related to a specific package?
Checklist