Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce lucid-evolution and wasm compatibility to the frontend #64

Merged
merged 16 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/ci-oci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,11 @@ jobs:
# except the version with the `primary-key`, if it exists
purge-primary-key: never

# TODO: matrix build for two images (mock server and wst)
- name: Build image with nix
if: False
run: nix build --accept-flake-config .#containers.x86_64-linux.${{ matrix.image }}.copyTo
- name: Publish tagged image with podman
if: False
run: |
IMAGE_NAME=ghcr.io/${{github.repository_owner}}/${{ matrix.image }}:$IMAGE_TAG
./result/bin/copy-to oci-archive:oci.tar
Expand Down
65 changes: 64 additions & 1 deletion frontend/next.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');


/** @type {import('next').NextConfig} */
const nextConfig = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need a line output = "export" for the docker image (to generate a single static page). This line won't work with the headers bit, so maybe we need two different configs, or look at debug vs production flags?

Copy link
Collaborator

@KJES4 KJES4 Jan 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can do that but then it will most likely create conflicts with the rewrites. This is what I get from NextJS when I try to use both the rewrites and the output="export" at the same time. https://nextjs.org/docs/messages/export-no-custom-routes

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the production build we don't need the rewrites anyway, so we can just switch between two different configs based on the flag

Copy link
Collaborator

@KJES4 KJES4 Jan 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I comment out the rewrites in the commit so that the Nix build works?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be ok now

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the tests still failed. Should I merge it or wait for that to pass?

output: 'export',
// output: 'export',
serverExternalPackages: [
"@lucid-evolution/lucid",
],
async headers() {
return [
{
Expand All @@ -24,6 +29,64 @@ const nextConfig = {
},
];
},
async redirects() {
return [
{
source: '/',
destination: '/mint-authority',
permanent: true, // Use true for a 301 redirect, false for 302
},
];
},
experimental: {
esmExternals: true, // Ensure modern module support
},
webpack: (config, { isServer }) => {
// Ensure `resolve.plugins` exists
config.resolve.plugins = [
...(config.resolve.plugins || []), // Keep existing plugins
new TsconfigPathsPlugin({
configFile: './tsconfig.json', // Adjust the path to your tsconfig.json if necessary
}),
];

config.experiments = {
...config.experiments,
asyncWebAssembly: true, // Enable async WebAssembly
topLevelAwait: true,
layers: true
};
if (!isServer) {
config.output.environment = { ...config.output.environment, asyncFunction: true };
}

// Add fallback and resolve configurations for browser compatibility
config.resolve = {
...config.resolve,
extensions: ['.ts', '.tsx', '.js', '.mjs'],
fallback: {
https: require.resolve('https-browserify'),
http: require.resolve('stream-http'),
'get-port-please': false,
net: false,
fs: false,
os: false,
path: false,
events: require.resolve('events/'),
buffer: require.resolve('buffer/'),
stream: require.resolve('readable-stream'),
crypto: require.resolve('crypto-browserify'),
constants: require.resolve('constants-browserify'),
zlib: require.resolve('browserify-zlib'),
dns: false,
tls: false,
process: false,
child_process: false,
},
};

return config;
},
};

module.exports = nextConfig;
Expand Down
Empty file removed frontend/next.config.mjs
Empty file.
Loading
Loading