-
Notifications
You must be signed in to change notification settings - Fork 298
-
Notifications
You must be signed in to change notification settings - Fork 298
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 Error when using momentjs #290
Comments
Try using
|
thanks for putting the repro up! $ DEBUG=true yarn build
yarn run v1.3.2
$ ng-packagr -p ng-package.json
Building Angular library
[debug] Searching for ng-package config at #/moment-ng-packagr/ng-package.json
[debug] Ng-package config found at #/moment-ng-packagr/ng-package.json
[debug] loading package.json
[debug] Beginning package search from root #/moment-ng-packagr
[debug] Resolved secondary package paths:
[debug] rimraf #/moment-ng-packagr/dist
Generating bundle for moment-ng-packagr
Cleaning bundle build directory
[debug] rimraf #/moment-ng-packagr/.ng_pkg_build/moment-ng-packagr
Processing assets
[debug] processAssets #/moment-ng-packagr to #/moment-ng-packagr/.ng_pkg_build/moment-ng-packagr/ts
[debug] render stylesheet #/moment-ng-packagr/src/time-line.component.css
[debug] postcss with autoprefixer for #/moment-ng-packagr/src/time-line.component.css
Running ngc
[debug] ngc #/moment-ng-packagr/.ng_pkg_build/moment-ng-packagr/ts/tsconfig.lib.json, { basePath: #/moment-ng-packagr/.ng_pkg_build/moment-ng-packagr/ts })
[debug] prepareTsConfig: Resolved tsconfig path to #/moment-ng-packagr/node_modules/ng-packagr/lib/conf/tsconfig.ngc.json
[debug] Reading tsconfig from #/moment-ng-packagr/.ng_pkg_build/moment-ng-packagr/ts/tsconfig.lib.json
[debug] re-mapping sources for #/moment-ng-packagr/.ng_pkg_build/moment-ng-packagr/ts/moment-ng-packagr.js
Compiling to FESM15
[debug] rollup #/moment-ng-packagr/.ng_pkg_build/moment-ng-packagr/ts//moment-ng-packagr.js to #/moment-ng-packagr/.ng_pkg_build/moment-ng-packagr/moment-ng-packagr.js (es) So this is not a ngc / tsc compile error but rollup goes bust when budling the individual js files to a flat es module file. Here are some related answers to moment.js and rollup:
Can you tell if any of these and which one works for you? FYI: The rollup config ng-packagr generates is the following ( {
"context": "this",
"external": [
/* angular and rxjs default config here ... */
"moment"
],
"input": "#/moment-ng-packagr/.ng_pkg_build/moment-ng-packagr/ts//moment-ng-packagr.js",
"plugins": [
nodeResolve({ jsnext: true, module: true }),
commonJs(),
]
} |
Thank you very much for your fast response!
Works fine for me. The
Adding a tsconfig.json with allowSyntheticDefaultImports set in the project root does not change anything. (as far as I understand I cannot change the tsconfig.json file for the ng-packagr). I will for now use the moment-es6 workaround. It would still be nice to be able to get rid of it. Thanks very much for you time and this awesome project. |
Yeah, I had the same problem with the |
Ok, I dedicated moment.js its own section in that not-so-famous #129 :-) |
By the way, I just switched to
|
For a different workaround without the need to use |
@crowmagnumb Did you ever figure out a solution to this? Having the same issue now... |
@elliotleelewis Yeah, as I indicated above I imported |
@crowmagnumb Apologies, I misread your initial comment. I'm getting that same error when using What version are you using that isn't getting that error? |
2.18.1. Can you give us code examples and output? |
This issue has been automatically locked due to inactivity. |
Type of Issue
Description
As a few people before me, I cannot run ng-packagr when using moment. I tried the suggested solutions in other issues but I cannot get it to work.
I added the following:
When using
import * as moment from 'moment';
I get the following
When using
import moment from 'moment'
How To Reproduce
Include moment into something and try to run ng-packagr
I uploaded a small example of my setup to GitHub where the issue is reproducible
https://github.com/Nevergonnachange/moment-ng-packagr/tree/master/src
Expected Behaviour
Build passes
Version Information
Thank you very much in advance.
The text was updated successfully, but these errors were encountered: