[ ] Bug Report
[ ] Feature Request
[x] Question
I need to embed an external javascript file in my library. I have no ideo how to do that. In the docs there are examples for npm packages but not for plain javascript files.
I tried several ideas with lib.embedded or lib.externals without luck.
This is my project structure:
├── lib
│  ├── janus-api.js
│  └── janus-web-rtc-subject.ts
{
"$schema": "./node_modules/ng-packagr/ng-package.schema.json",
"dest": "dist",
"lib": {
"externals": {
"./src/lib/janus-api.js": "Janus"
},
"entryFile": "public_api.ts"
},
"whitelistedNonPeerDependencies": ["."]
}
Now the janus-web-rtc-subject.ts file imports the janus-api.js and uses some functions.
The code looks ok but ng-packagr failes to bundle that structure.
import Janus from './janus-api.js';
import {Observable, Subject} from 'rxjs';
export class JanusWebRtcSubject {
...
And the error is
BUILD ERROR
Could not resolve './janus-api.js' from dist\esm2015\src\lib\janus-web-rtc-subject.js
Error: Could not resolve './janus-api.js' from dist\esm2015\src\lib\janus-web-rtc-subject.js
Bundle the janus-api.js in the lib via externals or embedded.
ng-packagr: 3.0.3
@angular/compiler: 6.0.7
rollup: 0.59.4
tsickle: 0.29.0
typescript: 2.7.2
rxjs: 6.2.1
node: v8.11.1
npm: 6.1.0
Duplicate of https://github.com/dherges/ng-packagr/issues/650
try to make your external javascript to be a common 3rd party and npm install it. So you could use it everywhere in you proj. Do it like this: create a folder name 'anus-api' and put 'anus-api.js' and 'package.json' into it, then run 'npm pack ' in this folder so that there would build a tgz fild. And you could import the tgz file in you proj's package.json. So you could use the external javascript in your proj
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._
Most helpful comment
try to make your external javascript to be a common 3rd party and npm install it. So you could use it everywhere in you proj. Do it like this: create a folder name 'anus-api' and put 'anus-api.js' and 'package.json' into it, then run 'npm pack ' in this folder so that there would build a tgz fild. And you could import the tgz file in you proj's package.json. So you could use the external javascript in your proj