embroider icon indicating copy to clipboard operation
embroider copied to clipboard

`staticComponents` misses sub-components with an unused parent

Open fdeters opened this issue 1 year ago • 1 comments

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:

  • @embroider/compat 3.2.3
  • @embroider/core 3.3.0
  • @embroider/webpack 3.2.0
  • @ember/source 5.4.0
  • ember-template-imports 4.0.0

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',
                    },
                  },
                },
              ],
            },
          ],
        },
      },
    },
  });

fdeters avatar Jan 02 '24 20:01 fdeters

I've got the same problem

pulien avatar Mar 19 '24 16:03 pulien