vercel / turborepo

Build system optimized for JavaScript and TypeScript, written in Rust
https://turbo.build/repo/docs
MIT License
26.21k stars 1.81k forks source link

StyledComponents config should allow empty topLevelImportPaths & meaninglessFileNames array #8941

Closed ivoba closed 2 months ago

ivoba commented 2 months ago

Verify canary release

Link to code that reproduces this issue

https://github.com/ivoba/turborepo-styledcomponents-warning

What package manager are you using / does the bug impact?

npm, Yarn v2/v3/v4 (node_modules linker only)

What operating system are you using?

Mac

Which canary version will you have in your reproduction?

turbo@2.0.12-canary.1

Describe the Bug

Using the recommended styledComponents config from here: https://nextjs.org/docs/architecture/nextjs-compiler#styled-components

module.exports = {
  compiler: {
    // see https://styled-components.com/docs/tooling#babel-plugin for more info on the options.
    styledComponents: {
      // Enabled by default in development, disabled in production to reduce file size,
      // setting this will override the default for all environments.
      displayName?: boolean,
      // Enabled by default.
      ssr?: boolean,
      // Enabled by default.
      fileName?: boolean,
      // Empty by default.
      topLevelImportPaths?: string[],
      // Defaults to ["index"].
      meaninglessFileNames?: string[],
      // Enabled by default.
      cssProp?: boolean,
      // Empty by default.
      namespace?: string,
      // Not supported yet.
      minify?: boolean,
      // Not supported yet.
      transpileTemplateLiterals?: boolean,
      // Not supported yet.
      pure?: boolean,
    },
  },
}

This will render a warning:

⚠ Array must contain at least 1 element(s) at "compiler.styledComponents.topLevelImportPaths" ⚠ Array must contain at least 1 element(s) at "compiler.styledComponents.meaninglessFileNames"

Json schema definition: https://github.com/vercel/turbo/blob/49c67593edb6c2c1389d38ab61cbb3ece3810c92/crates/turbopack-ecmascript-plugins/src/transform/styled_components.rs#L34C13-L34C35

This should probably allow empty Arrays, same goes for meaninglessFileNames

Expected Behavior

There should be no confusing warnings for the recommended styledcomponents configuration.

To Reproduce

  1. Checkout the example repo: https://github.com/ivoba/turborepo-styledcomponents-warning
  2. Install deps: npm i
  3. Run: npm run dev -w=app-a
  4. See warnings in console

Additional context

No response

Netail commented 2 months ago

turbopack has moved to vercel/nextjs :)

chris-olszewski commented 2 months ago

As mentioned above, Turbopack now resides in https://github.com/vercel/next.js so you should open your issue there according to their issue template.