Ng-packagr: Embedded angular/core into the bundle

Created on 22 Feb 2018  路  4Comments  路  Source: ng-packagr/ng-packagr

Type of Issue

[ ] Bug Report
[ ] Feature Request
[X] Support 

Description

I can't embedded angular/core into my library

How To Reproduce

With this configuration when i exec ng-packagr -p package.json i get this error:

package.json

"ngPackage": {
    "lib": {
      "$schema": "./node_modules/ng-packagr/ng-package.schema.json",
      "languageLevel": [
        "dom",
        "es2017"
      ],
      "cssUrl": "inline",
      "licensePath": "LICENSE",
      "comments": "none",
      "embedded": [
        "lodash",
        "@angular/core"
      ],
      "entryFile": "src/public_api.ts"
    }
  },

public_api.ts

import * as lodash from "lodash";
import * as core from "@angular/core";

const _ = lodash;
const ng = core;

export {
  _,
  ng
}

Console output

yarn run v1.3.2
$ ng-packagr -p package.json
Building Angular Package
Building entry point 'core'
Cleaning build directory
Rendering Stylesheets
Rendering Templates
Compiling TypeScript sources through ngc
Bundling to FESM15

BUILD ERROR
ENOENT: no such file or directory, open 'C:\Users\hecto\Desktop\core\node_modules\packages\core\esm5\src\di\injection_token.js.map'
Error: ENOENT: no such file or directory, open 'C:\Users\hecto\Desktop\core\node_modules\packages\core\esm5\src\di\injection_token.js.map'

error Command failed with exit code 111.

Expected Behaviour

I trying to expose angular core from my library and consume it in an other SPA.

Version Information

$ node_modules/.bin/ng-packagr --version
ng-packagr: 2.1.0
@angular/compiler: 5.2.6
@angular/compiler-cli: 5.2.6
rollup: 0.55.5
tsickle: 0.27.2
typescript: 2.5.0
rxjs: 5.5.6
node: 9.5.0
yarn: 1.3.2

Thanks you very much in advance :)

question

All 4 comments

Looks like a source map issue in @angular/core ?

Alltogether, I wouldn't do that and try to embed angular code or rxjs in a bundle. I know I showed it on the angularair podcast but I shouldn't. Embedding a dependency is appropriate if you like to provide a wrapper around a third-party and imo that's only a good idea for legacy or plain javascript. For example, a shim or a 'native' XHR library and there you like to hide the awkwardness(?) from your consumers.

okk, i was understand you.
My intention is that this package provide the correct version of angular 5, because i don't want that the developers in my project using other versions. But from your comment i thinking that is better idea that i indicate the specific version in dependencies and peerDependencies and in the SPAs only use as dependency my package.

What are you think about this?

Thanks

add @angular/core to peerDeps

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

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings