text-mask: Error on new Ionic2 RC0 with AoT compiler
After upgrading ionic2 to RC0 and using AoT compiler this error occurred in build time:
ngc error: Error: can't find symbol undefined exported from module /home/araz/Desktop/bluedot/node_modules/angular2-text-mask/dist/angular2TextMask.d.ts, resolving symbol AppModule in /home/test/.tmp/app/app.module.ts, resolving symbol AppModule in /home/test/.tmp/app/app.module.ts
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 42 (24 by maintainers)
@fernandobandeira
TextMaskModulebelongs in theimportsarray not in thedeclarationsarray.@msafi
I could be wrong here, I haven’t caught up with the latest build tools and I might be missing out on something. But here are my thoughts according to what I know:
First of all, we have this issue because we weren’t publishing
.metadata.jsonwith our bundle. That is the file thatngcneeds in order to successfully import your component/service/module in an Angular 2 app. That file is generated when we compile the code usingngc. If you go ahead and use Webpack to bundle whatngcoutputted, then the.metadata.jsonfile will not match the.jsfile and we will run into issues.So that being said, the options we have are:
importstatement. But that wouldn’t make sense because we don’t want to have duplicate code in the repo.The proposed final result would end up like:
@text-mask/core
/dist/directory will contain ES5/ES6 files with their typings, a bundle (webpack/browserify), and a minified version of the bundle@text-mask/angular2
@text-mask/coreand@text-mask/commonwill be defined in the dependencies inpackage.json/dist/directory will contain ES5/ES6 files with their typings@text-mask/addons @text-mask/common
@text-mask/vanilla @text-mask/react @text-mask/vue @text-mask/ember
@text-mask/coreand@text-mask/common, we should also publish typings when possible to provide maximum language support.@msafi
Yeah just had a look, I managed to compile it properly but it needs
../coredirectory to be present. Which wouldn’t work out for the NPM module.We can maybe import the core library from the npm package instead of the relative path. It might complicate the build process but due to your project’s layout, that might be our only option.
You can look into using scopes for
npmtoo so you can have:@msafi Another reason to break this big repo into smaller repos:
I just opened the project on a fresh Windows install, using WebStorm 2016.3 EAP. My IDE indexed the project on first launch as usual, and then decided to treat the whole project as a JSX (React) project. This means I would have to manually change the project settings to match what I’m working with (ES2015 or JSX or ES5).
Not a big deal, just wanted to add this to the list of reasons 😃
@ihadeed I ran into the same issue.
@msafi what do you think about splitting the project into separate repositories? One for the core and then directives/functions for each framework.
@msafi I just tried it with a clean repository and it works like a charm.
@msafi AoT depends typescipt 2.0 the tsconfig should be adjust, start repo isolate github and npmjs but text-mask-core hit me (I think that can rewrite in typescript 2 and eliminate the babel). In case not separate think each folder should be thought of as a module see angular2
Tell me if I can help with something (refactoring text-mask-core to typescript, process publish isolate …)
Thanks
@PerfectPixel +1 Best form is separate and manage dependencies with peerDependencies
@msafi shouldn’t it just be compiled with ngc instead of tsc as described here: https://medium.com/@isaacplmann/getting-your-angular-2-library-ready-for-aot-90d1347bcad#.2sby5kwm5
@msafi @jafaripur Take a look this article I guess you need to have *.metadata.json for AoT complier. Also, #2 in that article can resolve the issue.