Can’t package up module for npm when using mdb


Topic: Can’t package up module for npm when using mdb

Pinzon pro asked 7 years ago

Hey guys,

I've created a couple of  modules that wanted to package up and push to my private npm repo for later consumption but it appears using MDB it's causing issues.

I use ng-packagr which so far was work every time for all modules except for my latest modules where I incorporate MDB.The first "issue" (not really) is the fact that ng-packagr flags ng-mdb-pro as a dependency that can't be resolve so it treats is an external. Here's the exact log

"'ng-mdb-pro' is imported by .ng_pkg_build\@xxx-ng-yyy\ts\src\app\modules\aaa-bbb\aaa-bbb.module.js, but could not be resolved – treating it as an external dependency"

That's not really a problem as I wasn't expecting it include the library in the bundle. Note that updating package.json to include ng-mdb-pro as either dependency or peer dependency makes no difference.

Other than that message, the packaging appears to run fine, except it doesn't. The dist folder (which is where the packager dumps the files) misses everything under the module folder including the .module.d.ts. That means no components, no services.. nothing. If I remove the reference to  MDBBootstrapModules from the imports and run the packager, it all runs smoothly and dist folder has got what I'd expect to see.

At some point I thought I could cheat by packaging up the solution without MDB, save the missing files, then run it again with the reference to MDB, add the missing files I had saved previously to the dist folder and publish it to npm. Although this got me passed the issue of not being able to find my module (because the files weren't there), it didn't get much further. This is the error that I get in the project which using my  module imported from npm:

"ERROR in ./node_modules/@xxx/ng-yyy/node_modules/ng-mdb-pro/index.tsModule build failed: Error: C:\projects\aaa-bbb\node_modules\@xxx\ng-yyy\node_modules\ng-mdb-pro\index.ts is not part of the compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property."

That's as far as I've gotten, I was hoping you guys could shed some light as to what's the proper solution setup so I can include MDB as part of my library


Dawid Adach pro answered 7 years ago

Dear Pinzon, thank you for a detailed input, unfortunately, we've never used np-packagr, therefore, we can't help much. I would suggest commenting all modules within MDB PRO, and try to uncomment some of them to check if at least any is getting packed into your package. If not then issue lays in more generic plays, if some of them are getting packed while others, not that will allow narrow down the issue to certain components.
Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue
  • User: Pro
  • Premium support: No
  • Technology: MDB Angular
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: Yes
  • Provided link: No