Skip to content

Rollup config error on dynamic import during library build #14444

@GeorgeKnap

Description

@GeorgeKnap

🐞 Bug report

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

Is this a regression?

No

Description

Consider building foo library with the command ng build foo.
When the library contains a file (service in my case), which uses dynamic import, the build will fail throwing error below. This happens in v7 and also after upgrading to v8.0.0-rc.4

🔬 Minimal Reproduction

  1. Create a new project. Generate library ng g library foo.
  2. Create a service in the library that is using dynamic imports. (example screenshot below)
  3. Export service in public-api.ts
  4. Build library with ng build shared
    Capture

🔥 Exception or Error



Building Angular Package
Building entry point 'testik'
Compiling TypeScript sources through ngc
Bundling to FESM2015

BUILD ERROR
You must set "output.dir" instead of "output.file" when generating multiple chunks.
Error: You must set "output.dir" instead of "output.file" when generating multiple chunks.
    at error (c:\Development\rollup-test\node_modules\rollup\dist\rollup.js:3410:30)
    at normalizeOutputOptions (c:\Development\rollup-test\node_modules\rollup\dist\rollup.js:17107:13)
    at getOutputOptions (c:\Development\rollup-test\node_modules\rollup\dist\rollup.js:16865:24)
    at Object.write (c:\Development\rollup-test\node_modules\rollup\dist\rollup.js:16957:43)
    at Object. (c:\Development\rollup-test\node_modules\ng-packagr\lib\flatten\rollup.js:46:22)
    at Generator.next ()
    at fulfilled (c:\Development\rollup-test\node_modules\ng-packagr\lib\flatten\rollup.js:4:58)

🌍 Your Environment


Angular CLI: 8.0.0-rc.4
Node: 10.15.0
OS: win32 x64
Angular: 8.0.0-rc.4
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.800.0-rc.4
@angular-devkit/build-angular      0.800.0-rc.4
@angular-devkit/build-ng-packagr   0.800.0-rc.4
@angular-devkit/build-optimizer    0.800.0-rc.4
@angular-devkit/build-webpack      0.800.0-rc.4
@angular-devkit/core               8.0.0-rc.4
@angular-devkit/schematics         8.0.0-rc.4
@angular/cdk                       8.0.0-rc.1
@angular/flex-layout               7.0.0-beta.24
@angular/material                  8.0.0-rc.1
@ngtools/json-schema               1.1.0
@ngtools/webpack                   8.0.0-rc.4
@schematics/angular                8.0.0-rc.4
@schematics/update                 0.800.0-rc.4
ng-packagr                         5.1.0
rxjs                               6.5.2
typescript                         3.4.5
webpack                            4.30.0

Anything else relevant?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions