Probable Bug - Adding Entry elements overwrites main
This is preliminary bug report. When I add a few folders in the entry, it overwrites the basic entry points like main, etc.
I added the following custom webpack in my project.
const path = require("path");
const fs = require("fs");
//const webpack = require("webpack");
var entry = { };
fs.readdirSync(path.join(__dirname, "api/controllers"))
.filter((f) => path.parse(f).ext.toLowerCase() === ".js")
.forEach((f) => {
var name = path.parse(f).name;
entry["api/controllers/" + name] = path.join(
__dirname,
"api/controllers",
f
);
});
fs.readdirSync(path.join(__dirname, "api/models"))
.filter((f) => path.parse(f).ext.toLowerCase() === ".js")
.forEach((f) => {
var name = path.parse(f).name;
entry["api/models/" + name] = path.join(__dirname, "api/models", f);
});
module.exports = {
entry: entry,
};
After trying to dev or build, I get the following errors:
Compiled successfully.
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module '/Users/prabhatsingh/helossr/dist/vito-angular/server/main.js'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
A server error has occurred.
node exited with 1 code.
connect ECONNREFUSED 127.0.0.1:64399
Minimal Reproduction
Node v16 LTS, MacOS Catalina Built with ng-universal.
Expected Behavior
Since, I added the "append" flag for custom webpack, I was expecting it to retain existing entries. But seemingly it overwrites all the entries.
Hi. Please provide a link to a minimal reproduction repo.
Here I have created a minimal repo to reproduce this behaviour. https://github.com/aaryavrate/ngunidemo
Why would you use DefinePlugin for the extra config? Seems like a misuse to me.
I have to add the files in api/ctrls to path of webpack. I don't know a better way than DefinePlugin. This , I assume, shall help in adding variables at compile time. Is there a suitable way? Please help
Any updates please?
Hey, I have looked at your example, but I'm not able to understand what you're trying to achieve. The DefinePlugin is used to define global constants which are replaced within the code during the AST transformation. You're not using it correctly and this is not how it should be used.
Closing as not an issue in the core builder itself.