Skip to content
Snippets Groups Projects
Verified Commit 615beb2b authored by Mateusz Tyszczak's avatar Mateusz Tyszczak :scroll:
Browse files

Make webpack-based examples work with new version of wax

parent 1354a11f
No related branches found
No related tags found
No related merge requests found
Pipeline #113831 failed
......@@ -3,7 +3,7 @@
"packageManager": "pnpm@9.15.4+sha512.b2dc20e2fc72b3e18848459b37359a32064663e5627a51e4c74b2c29dd8e8e0491483c3abb40789cfd578bf362fb6ba8261b05f0387d76792ed6e23ea3b1b6a0",
"scripts": {
"pretest": "playwright install",
"test": "pnpx tsx index.ts"
"test": "rm -rf ./.parcel-cache ./dist && pnpx tsx index.ts"
},
"devDependencies": {
"@parcel/config-default": "^2.12.0",
......
......@@ -3,25 +3,3 @@
Created by command: `npx create-next-app@latest nextjs-app`
[pages/index.tsx](pages/index.tsx) file was modified
Changes made in order for React + Next.js app to work:
```diff
const nextConfig = {
reactStrictMode: true,
+ webpack: (config, { isServer }) => {
+ if (!isServer) // Prevents client bundles from including node specific packages required for WASM loading in wax
+ config.resolve.fallback = {
+ fs: false,
+ path: false,
+ module: false
+ };
+
+ return config;
+ }
};
export default nextConfig;
```
As you can see, we had to extend webpack configuration, ensuring `fs`, `path` and `module` dependencies are omitted from bundling as code importing them will be unreachable on the client-web-side
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
webpack5: true, // Enabled by default - just to be sure - follow this guide if using webpack <5 - https://bobbyhadz.com/blog/module-not-found-cant-resolve-fs#module-not-found-cant-resolve-fs-error-in-nextjs
webpack: (config, { isServer }) => {
if (!isServer) // Prevents client bundles from including node specific packages required for WASM loading in wax
config.resolve.fallback = {
fs: false,
path: false,
module: false
};
return config;
}
reactStrictMode: true
};
export default nextConfig;
......@@ -9,11 +9,8 @@ export default defineConfig({
optimizeDeps: { // Affects only dev build
exclude: ['@hiveio/wax'],
include: [
'@hiveio/wax > class-validator',
'@hiveio/wax > class-transformer',
'@hiveio/wax > long',
'@hiveio/wax > events',
'@hiveio/wax > reflect-metadata'
'@hiveio/wax > events'
]
}
})
......@@ -3,22 +3,3 @@
Created by command: `vue create vue-webpack` ([`@vue/cli` package](https://www.npmjs.com/package/@vue/cli))
[src/App.vue](src/App.vue) file was modified
Changes made in order for Vue + Webpack to work:
```diff
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
transpileDependencies: true,
+ configureWebpack: config => {
+ config.resolve.fallback = {
+ fs: false,
+ path: false,
+ module: false,
+ crypto: false
+ };
+ }
})
```
As you can see, we had to extend webpack configuration, ensuring `fs`, `path`, `module` and `crypto` dependencies are omitted from bundling as code importing them will be unreachable on the client-web-side
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
transpileDependencies: true,
configureWebpack: (config) => {
config.resolve.fallback = {
fs: false,
path: false,
module: false,
crypto: false
};
}
transpileDependencies: true
})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment