webpack-external-import icon indicating copy to clipboard operation
webpack-external-import copied to clipboard

Question: Are nested componenst/modules supported without adding them to interleave

Open ChrisMalherbe opened this issue 5 years ago • 2 comments

Hi,

Thank you for the work on webpack-external-import.

I have a question, is it possible to have child components of an interleaved component automatically available to the container application.

If we changed the vendor application to import another local component like this:

Screen Shot 2020-02-17 at 5 56 43 pm

Would we have to expose Title3 as interleaved as well, or is there a way to automatically expose Title3?

ChrisMalherbe avatar Feb 17 '20 06:02 ChrisMalherbe

I'm struggling to figure this out as well. Without this it does not seem very useful, as you can't define 100s of files that a micro-frontend could potentially have and have them all individually chunked, seems very inefficient.

From what I can gather looking at other github issues and various readings it is possible, it's just not documented. Trying to mess around with webpack chunks. Did you get anywhere with this?

Would be good if someone could shed some light on this, I've tried the following with no luck:

config.optimization.splitChunks.cacheGroups.microfrontend = {
  test: path.resolve('src'),
  name: 'microfrontend',
  chunks: 'all',
};

rickihastings avatar Jul 10 '20 08:07 rickihastings

After a lot of digging I've finally figured this out, I don't know if it's intended to function like this or a side effect, but you can do the following:

"interleave": {
  "src/HelloWorld.js": "website4_app"
},

Then in your webpack.config.js

config.optimization.splitChunks = {
  chunks: "all",
  maxInitialRequests: Infinity,
  minSize: 0,
  cacheGroups: {
    'website4_app': {
      test: /[\\/]src\/(.*)/,
      name: 'website4_app',
    },
  }
};

This will bundle any resources in ./src into the component bundle that this module creates.

rickihastings avatar Jul 11 '20 10:07 rickihastings