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

wasm plugins do not build in next.js #9

Open
tamird opened this issue Dec 18, 2023 · 0 comments
Open

wasm plugins do not build in next.js #9

tamird opened this issue Dec 18, 2023 · 0 comments

Comments

@tamird
Copy link

tamird commented Dec 18, 2023

In my application I have utility libraries that are shared between a typescript CLI program and a web app. The interface exposed by the various plugins (e.g. @dprint/markdown) doesn't work play nice with build tools like next.js which want to bundle everything statically. In particular, I have the following code:

const markdownFormatter = createFromBuffer(readFileSync(markdownPath()));
// https://dprint.dev/plugins/markdown/config/
markdownFormatter.setConfig(
  {
    lineWidth: 80,
  },
  {},
);
markdownFormatter.getConfigDiagnostics().forEach((diagnostic) => {
  console.error(
    `markdown formatter config diagnostics property=${diagnostic.propertyName}: ${diagnostic.message}`,
  );
});

const typescriptFormatter = createFromBuffer(readFileSync(typescriptPath()));
// https://dprint.dev/plugins/typescript/config/
typescriptFormatter.setConfig(
  {
    lineWidth: 110,
  },
  {
    'arrowFunction.useParentheses': 'force',
    quoteStyle: 'alwaysSingle',
  },
);

typescriptFormatter.getConfigDiagnostics().forEach((diagnostic) => {
  console.error(
    `typescript formatter config diagnostics property=${diagnostic.propertyName}: ${diagnostic.message}`,
  );
});

and attempting to build this with next.js produces:

Error: ENOENT: no such file or directory, open '/path/to/project/services/app/.next/server/chunks/plugin.wasm'
    at Object.openSync (node:fs:581:18)
    at readFileSync (node:fs:457:35)
    at 50509 (/path/to/project/services/app/.next/server/chunks/707.js:3:163)
    at t (/path/to/project/services/app/.next/server/webpack-runtime.js:1:143)
    at 19428 (/path/to/project/services/app/.next/server/app/(studio)/[orgName]/[projectName]/studio/page.js:236:5398)
    at Function.t (/path/to/project/services/app/.next/server/webpack-runtime.js:1:143)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async collectGenerateParams (/path/to/project/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/build/utils.js:884:17) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/path/to/project/services/app/.next/server/chunks/plugin.wasm'
}

> Build error occurred
Error: Failed to collect page data for /[orgName]/[projectName]/studio
    at /path/to/project/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/build/utils.js:1220:15
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  type: 'Error'
}
   Collecting page data  . ELIFECYCLE  Command failed with exit code 1.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant