Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build of server side bundle is combining to the bundle packages which are linked. #13817

Closed
majo44 opened this issue Mar 5, 2019 · 1 comment · Fixed by #13819
Closed

Build of server side bundle is combining to the bundle packages which are linked. #13817

majo44 opened this issue Mar 5, 2019 · 1 comment · Fixed by #13819
Labels
area: devkit/build-angular freq1: low Only reported by a handful of users who observe it rarely severity3: broken type: bug/fix
Milestone

Comments

@majo44
Copy link
Contributor

majo44 commented Mar 5, 2019

🐞 Bug report

Command

- [ ] new
- [x] build
- [x] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [x] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Description

Build of server side bundle is combining to the bundle packages which are linked (npm link xyz). Same package, if is just installed (npm i xyz) is just referenced by require. This cause a problems with few workflows like auto server side restart by nodemon, debugging, ect. It is confusing that build is handling same package in two different ways. Build should handle in same way packages which are under node_modules, no matter haw that modules are installed.

🔬 Minimal Reproduction

  1. ng init abc
  2. cd abc
  3. npm i uuid @types/uuid (this is just example of some 3Party package, but it can be any other)
  4. create file src/main-server.ts:
import {v4} from 'uuid';
console.log(v4());
  1. create file src/tsconfig.server.json:
{
  "extends": "../tsconfig.json",
  "compilerOptions": { "outDir": "../out-tsc/server", "module": "commonjs" }
}
  1. in angular.json under the projects/abc/architect add:
...
"server": {
  "builder": "@angular-devkit/build-angular:server",
  "options": {
    "bundleDependencies": "none", <-- this doesn't help :(
    "preserveSymlinks": true,
    "outputPath": "dist/server",
    "main": "src/main-server.ts",
    "tsConfig": "src/tsconfig.server.json",
    "fileReplacements": [
      {
        "replace": "src/environments/environment.ts",
        "with": "src/environments/environment.prod.ts"
      }
    ]
  }
}
...
  1. call ng run abc:server, generated bundle is 4.55 kB and contains just reference to uuid package:
/***/ "uuid":
/*!***********************!*\
  !*** external "uuid" ***!
  \***********************/
/*! no static exports found */
/***/ (function(module, exports) { module.exports = require("uuid");/***/ })
/******/ })));
  1. now clone the package git clone https://github.com/kelektiv/node-uuid.git -- node-uuid
  2. link cloned package by npm link instde cloned repo
  3. under the abc project link uuid package by npm link uuid
  4. build bundle again by ng run abc:server, now bundle size is 11.2 kB and it contains content of linked package

🌍 Your Environment


Angular CLI: 7.3.4
Node: 10.15.1
OS: win32 x64
Angular: 7.2.7
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.13.4
@angular-devkit/build-angular     0.13.4
@angular-devkit/build-optimizer   0.13.4
@angular-devkit/build-webpack     0.13.4
@angular-devkit/core              7.3.4
@angular-devkit/schematics        7.3.4
@angular/cli                      7.3.4
@ngtools/webpack                  7.3.4
@schematics/angular               7.3.4
@schematics/update                0.13.4
rxjs                              6.3.3
typescript                        3.2.4
webpack                           4.29.0
@alan-agius4 alan-agius4 added type: bug/fix freq1: low Only reported by a handful of users who observe it rarely severity3: broken area: devkit/build-angular labels Mar 5, 2019
@ngbot ngbot bot added this to the Backlog milestone Mar 5, 2019
hansl pushed a commit that referenced this issue Mar 6, 2019
…`bundleDependencies` in `none` in server builder

Fixes #13817
hansl pushed a commit that referenced this issue Mar 6, 2019
…`bundleDependencies` in `none` in server builder

Fixes #13817
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: devkit/build-angular freq1: low Only reported by a handful of users who observe it rarely severity3: broken type: bug/fix
Projects
None yet
2 participants