Skip to content

Ionic umd module ids #434

@vilanz

Description

@vilanz

Type of Issue

[X] Bug Report
[ ] Feature Request

Description

Whenever I try to include something that uses anything from ionic-angular in my package, the building proccess breaks.
No matter what specific components/service/module I'm using, 99% of the time the file mentioned in the error is something in the utils folder,.

Building Angular library
Generating bundle for ion-with-packagr
Cleaning bundle build directory
Processing assets
Running ngc
Compiling to FESM15

BUILD ERROR
ENOENT: no such file or directory, open 'C:\...\...\...\...\ion-with-packagr\node_modules\ionic-angular\components\app\app-constants.ts'
Error: ENOENT: no such file or directory, open 'C:\...\...\....\...\ion-with-packagr\node_modules\ionic-angular\components\app\app-constants.ts'

I've read #129 and found a few issues related to this, which all can be solved by including the faulty package's UMD module ID in "externals" - I tried to use "ionicBundle" (shown below) for "ionic-angular", but no effect.

The new RCs seem to change something related to this, but I can't install them. (npm ERR! enoent ENOENT: no such file or directory, chmod 'C:............\ion-with-packagr\node_modules\ng-packagr\cli\main.js')

I've noticed Ionic seems to handle module IDs in a different way than other packages. I don't know if it could be related to this issue.

/ionic-angular/bundles/ionic.umd.js

(function (global, factory) {
   typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
   typeof define === 'function' && define.amd ? define(['exports'], factory) :
   (factory((global.ionicBundle = global.ionicBundle || {})));
}(this, (function (exports) { 'use strict';

/ionic-angular/umd/index.js

(function (factory) {
    if (typeof module === "object" && typeof module.exports === "object") {
        var v = factory(require, exports);
        if (v !== undefined) module.exports = v;
    }
    else if (typeof define === "function" && define.amd) {
        define(["require", "exports", "..._< bunch of stuff >_..."], factory);
    }
})(function (require, exports) {

How To Reproduce

  1. Start a new Angular project
  2. Install ionic-angular with --save (or just use the ionic start command as the first step)
  3. Install ng-packagr with --save-dev
  4. Set up a packaging environment and have a file be exported in public_api.ts
  5. In that file, import something from "ionic-angular" (the IonicModule or any component) and use it in the file itself
  6. Run ng-packagr -p -package.json

Expected Behaviour

Package ionic-angular properly and have it as a dependency.

Version Information

  "dependencies": {
    "@angular/common": "5.0.3",
    "@angular/compiler": "5.0.3",
    "@angular/compiler-cli": "5.0.3",
    "@angular/core": "5.0.3",
    "@angular/forms": "5.0.3",
    "@angular/http": "5.0.3",
    "@angular/platform-browser": "5.0.3",
    "@angular/platform-browser-dynamic": "5.0.3",
    "@ionic-native/core": "4.4.0",
    "@ionic-native/splash-screen": "4.4.0",
    "@ionic-native/status-bar": "4.4.0",
    "@ionic/storage": "2.1.3",
    "ionic-angular": "3.9.2",
    "ionicons": "3.0.0",
    "rxjs": "5.5.2",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.18"
  },
  "peerDependencies": {
    "ionic-angular": "3.9.2",
    "@ionic-native/core": "4.4.0",
    "@ionic-native/splash-screen": "4.4.0",
    "@ionic-native/status-bar": "4.4.0",
    "@ionic/storage": "2.1.3",
    "ionicons": "3.0.0"
  },
  "devDependencies": {
    "@ionic/app-scripts": "3.1.6",
    "ng-packagr": "^1.6.0",
    "typescript": "2.4.2"
  }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions