module-builder icon indicating copy to clipboard operation
module-builder copied to clipboard

pnpm pack error after 3.12.3 upgrade

Open matt-clegg opened this issue 1 year ago • 3 comments

Environment

Operating System: Linux Node Version: v20.5.1 Nuxt Version: 3.12.3 CLI Version: 3.12.0 Nitro Version: 2.9.7 Package Manager: [email protected] Builder: - User Config: - Runtime Modules: - Build Modules: -

This was also running inside a Docker container, using node:20.5-bullseye-slim as a base image.

Reproduction

I'm unable to create a reproduction of this issue as this from a large, internal project. This issue happens in our CI pipeline.

Describe the bug

After upgrading to Nuxt v3.12.3 our CI pipeline has started erroring when running pnpm pack.

This is the error:

RUN pnpm pack

> @xxxx/[email protected] prepack /src
> nuxt-module-build


 WARN  Please specify the build command explicitly. In a future version of @nuxt/module-builder, the implicit default build command will be removed.

ℹ Building yyyyy
ℹ Cleaning dist directory: ./dist

 ERROR  Cannot read properties of undefined (reading 'includes')

  at node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected][email protected]_sass@1._h47tfeevekwjm42weg4tnyrm3q/node_modules/@nuxt/module-builder/dist/chunks/build.mjs:171:86
  at Array.find (<anonymous>)
  at hasTypeExport (node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected][email protected]_sass@1._h47tfeevekwjm42weg4tnyrm3q/node_modules/@nuxt/module-builder/dist/chunks/build.mjs:171:62)
  at writeTypes (node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected][email protected]_sass@1._h47tfeevekwjm42weg4tnyrm3q/node_modules/@nuxt/module-builder/dist/chunks/build.mjs:177:7)
  at async rollup:done (node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected][email protected]_sass@1._h47tfeevekwjm42weg4tnyrm3q/node_modules/@nuxt/module-builder/dist/chunks/build.mjs:145:11)
  at async rollupBuild (node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]_/node_modules/unbuild/dist/index.mjs:721:3)
  at async _build (node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]_/node_modules/unbuild/dist/index.mjs:1087:3)
  at async build (node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]_/node_modules/unbuild/dist/index.mjs:945:5)
  at async Object.run (node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected][email protected]_sass@1._h47tfeevekwjm42weg4tnyrm3q/node_modules/@nuxt/module-builder/dist/chunks/build.mjs:43:5)
  at async runCommand (node_modules/.pnpm/[email protected]/node_modules/citty/dist/index.mjs:316:16) 

Our CI pipeline was running fine before upgrading to v3.12.3. I'm wondering if anyone else has seen this and what might have changed in this release for the pack command to break like this. Unfortunately there is no other information in the lofs that point to lines in our codebase.

I cant supply our source code as it's internal to our company. I hope this error is enough to be pointed in the right direction. I can provide other information, if needed.

Additional context

No response

Logs

No response

matt-clegg avatar Jul 03 '24 12:07 matt-clegg

Would you be able to provide a reproduction? 🙏

More info

Why do I need to provide a reproduction?

Reproductions make it possible for us to triage and fix issues quickly with a relatively small team. It helps us discover the source of the problem, and also can reveal assumptions you or we might be making.

What will happen?

If you've provided a reproduction, we'll remove the label and try to reproduce the issue. If we can, we'll mark it as a bug and prioritize it based on its severity and how many people we think it might affect.

If needs reproduction labeled issues don't receive any substantial activity (e.g., new comments featuring a reproduction link), we'll close them. That's not because we don't care! At any point, feel free to comment with a reproduction and we'll reopen it.

How can I create a reproduction?

We have a couple of templates for starting with a minimal reproduction:

👉 https://stackblitz.com/github/nuxt/starter/tree/v3-stackblitz 👉 https://codesandbox.io/s/github/nuxt/starter/v3-codesandbox

A public GitHub repository is also perfect. 👌

Please ensure that the reproduction is as minimal as possible. See more details in our guide.

You might also find these other articles interesting and/or helpful:

github-actions[bot] avatar Jul 03 '24 12:07 github-actions[bot]

I've think managed to reproduce the issue. The error was happening in our module.

Inside our module.ts file we have the following line: export * from "./runtime/composables/resources/generated/types";

This points to a file with about 3.4k lines of auto-generated types from our backend, this file was generated by NSwag. It looks something like:

// ----------------------
// <auto-generated>
//     Generated using the NSwag toolchain v14.0.7.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0)) (http://NSwag.org)
// </auto-generated>
// ----------------------

export interface FooRepresentation {
  key: string;
  label: string;
  url: string;
}

export interface BarDto {
  title?: string | undefined;
  description: string | undefined;
  flag: boolean;
}

// 3000 more lines of interfaces and enums...

Commenting out the line in module.ts to export the types allows the pnpm pack command to complete.

matt-clegg avatar Jul 04 '24 13:07 matt-clegg

So it seems the issue is caused by specifying a file inside the runtime folder is causing the pnpm pack error. I moved the generated types out of the runtime folder and changed the export command from export * from "./runtime/composables/resources/generated/types"; to export * from "./generated-types", and the pack command worked.

Should I no longer be exporting types from inside the runtime directory, or has a Nuxt change broken this functionality?

matt-clegg avatar Jul 05 '24 09:07 matt-clegg

I can confirm that moving the generated types out of the runtime directory fixes this issue.

matt-clegg avatar Aug 01 '24 14:08 matt-clegg