embroider-build / embroider

Compiling Ember apps into spec-compliant, modern Javascript.
MIT License
329 stars 137 forks source link

`staticComponents` misses sub-components with an unused parent #1747

Open fdeters opened 4 months ago

fdeters commented 4 months ago

When I was walking through enabling recommended Embroider options, I noticed that some components weren't making it into the build after I enabled staticComponents:

"Uncaught (in promise) Error: Attempted to resolve alert/taxlots-off, which was expected to be a component, but nothing was found."

I eventually narrowed down the issue to components that are defined in a subfolder that does not share a name with an existing component. For example, in the directory below, the taxlots-off component will not render (because there is no alert component), but the item component will render (because there is a tabs component).

app/
├─ components/
│  ├─ alert/
│  │  ├─ taxlots-off.gjs
│  ├─ tabs/
│  │  ├─ item.gjs
│  ├─ tabs.gjs

I tried creating an alert component, but nothing changed until I actually invoked the new alert component. When I added it just above the offending alert/taxlots-off component in the template, the error went away and everything rendered.

Ideally, components should make it into the build regardless of which subfolder they're in and whether or not they have a parent component in the directory (in my opinion).

Here are my potentially relevant package versions:

And my Embroider config:

return require('@embroider/compat').compatBuild(app, Webpack, {
    staticAddonTestSupportTrees: true,
    staticAddonTrees: true,
    staticHelpers: true,
    staticModifiers: true,
    staticComponents: true,
    // staticEmberSource: true,
    // splitAtRoutes: ['route.name'], // can also be a RegExp
    packagerOptions: {
      webpackConfig: {
        module: {
          rules: [
            {
              test: /\.css$/i,
              use: [
                {
                  loader: 'postcss-loader',
                  options: {
                    postcssOptions: {
                      config: 'postcss.config.js',
                    },
                  },
                },
              ],
            },
          ],
        },
      },
    },
  });
pulien commented 1 month ago

I've got the same problem