shlomiassaf / ngc-webpack

Angular compiler-cli with webpack's loader chain.
MIT License
84 stars 15 forks source link

Support for multiple entry points? #10

Closed dbettini closed 7 years ago

dbettini commented 7 years ago

Hello there. I'd like to know is it possible to make it work for multiple entry points? My app is structured of three packages, one is a node server and the other two are angular client apps. Those two are linked dependencies of the server, which bundles them. This is my configuration:

const tsClientNames = ["studio", "learn"];
tsClientNames.forEach(name => webpackConfig.module.rules.push({
    test: /\.tsx?$/,
    include: path.join(require.resolve(`${name}-client`), ".."),
    use: [
        {
            loader: "awesome-typescript-loader",
            options: {
                configFileName: path.join(require.resolve(`${name}-client`),"../tsconfig.json")
            }
        },
        "angular-router-loader",
        "angular2-template-loader"
    ]
}));

As you can see, both of them have their own tsconfig, libraries, types etc. It all works well in JIT, since I scoped the loaders through the 'include' property, so there are no conflicts. @ngtools/webpack does not support this, but since this lib is calling ngc after passing the loader chain, it seems possible, maybe by using separate ngc instances?

shlomiassaf commented 7 years ago

Hi @dbettini

Sorry for the late response.

The plugin does not handle multi-entry configurations since its not a bundler...

It's not the job of the plugin to do so.

Multi entry should be done from top level by separating configurations.

From the little you describe here, I think you should have a webpack configuration factory function that spit's out the right config per build.

Since the client does not depend on each other that's the right solution, IMHO.