angular-builders icon indicating copy to clipboard operation
angular-builders copied to clipboard

Probable Bug - Adding Entry elements overwrites main

Open aaryavrate opened this issue 4 years ago • 5 comments

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.

aaryavrate avatar Dec 17 '21 00:12 aaryavrate

Hi. Please provide a link to a minimal reproduction repo.

just-jeb avatar Dec 17 '21 13:12 just-jeb

Here I have created a minimal repo to reproduce this behaviour. https://github.com/aaryavrate/ngunidemo

aaryavrate avatar Dec 18 '21 19:12 aaryavrate

Why would you use DefinePlugin for the extra config? Seems like a misuse to me.

just-jeb avatar Dec 19 '21 12:12 just-jeb

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

aaryavrate avatar Dec 19 '21 18:12 aaryavrate

Any updates please?

aaryavrate avatar Dec 31 '21 08:12 aaryavrate

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.

arturovt avatar Nov 30 '22 15:11 arturovt