Skip to content
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

Ionic Meteor Production Builds failing. #1743

Closed
iLGunners opened this issue Nov 6, 2017 · 1 comment
Closed

Ionic Meteor Production Builds failing. #1743

iLGunners opened this issue Nov 6, 2017 · 1 comment

Comments

@iLGunners
Copy link

iLGunners commented Nov 6, 2017

Ionic Meteor application production build failing.

  • Modules in /home/noshu/code/ptc-gps/nexxdeli-mobile/node_modules are being discovered
  • Can't resolve meteor modules such as meteor/meteor
  • Can't resolve 'api/collections' and others in dir api/server/collections

Folder structure

image

Webpack config file

var path = require('path');
var webpack = require('webpack');
var ionicWebpackFactory = require(process.env.IONIC_WEBPACK_FACTORY);
 
module.exports = {
  entry: process.env.IONIC_APP_ENTRY_POINT,
  output: {
    path: '{{BUILD}}',
    publicPath: 'build/',
    filename: process.env.IONIC_OUTPUT_JS_FILE_NAME,
    devtoolModuleFilenameTemplate: ionicWebpackFactory.getSourceMapperFunction(),
  },
  devtool: process.env.IONIC_SOURCE_MAP_TYPE,
  // devtool: process.env.IONIC_GENERATE_SOURCE_MAP ? process.env.IONIC_SOURCE_MAP_TYPE : '',
 
  resolve: {
    extensions: ['.ts', '.js', '.json'],
    modules: [path.resolve('node_modules')],
    alias: {
      'api': path.resolve(__dirname, 'api/server')
    }
  },

  externals: [
    resolveExternals
  ],
 
  module: {
    loaders: [
      {
        test: /\.json$/,
        loader: 'json-loader'
      },
      {
        test: /\.ts$/,
        loader: process.env.IONIC_WEBPACK_LOADER
      },
      {
        test: /\.js$/,
        loader: process.env.IONIC_WEBPACK_TRANSPILE_LOADER
      }
    ]
  },
 
  // plugins: getPlugins(),
  plugins: [
    ionicWebpackFactory.getIonicEnvironmentPlugin(),
    new webpack.ProvidePlugin({
      __extends: 'typescript-extends'
    })
  ],
 
  // Some libraries import Node modules but don't use them in the browser.
  // Tell Webpack to provide empty mocks for them so importing them works.
  node: {
    fs: 'empty',
    net: 'empty',
    tls: 'empty',
    __dirname: true
  }
};

function resolveExternals(context, request, callback) {
  return resolveMeteor(request, callback) ||
    callback();
}
 
function resolveMeteor(request, callback) {
  var match = request.match(/^meteor\/(.+)$/);
  var pack = match && match[1];
 
  if (pack) {
    callback(null, 'Package["' + pack + '"]');
    return true;
  }
}

tsconfig

{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "baseUrl": ".",
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "downlevelIteration": true,
    "lib": [
      "es2015",
      "dom"
    ],
    "module": "commonjs",
    "moduleResolution": "node",
    "paths": {
      "api/*": ["./api/server/*"]
    },
    "sourceMap": true,
    "target": "es5",
    "skipLibCheck": true,
    "stripInternal": true,
    "removeComments": false,
    "noImplicitAny": false,
    "noEmitHelpers": true,
    "types": [
      "meteor-typings",
      "@types/underscore"
    ]
  },
  "include": [
    "src/**/*.ts",
    "api/**/*.ts"
  ],
  "exclude": [
    "node_modules",
    "api/node_modules",
    "api"
  ],
  "compileOnSave": false,
  "atom": {
    "rewriteTsconfig": false
  }
}

api/tsconfig

{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [
      "dom",
      "es2015"
    ],
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "target": "es5",
    "skipLibCheck": true,
    "stripInternal": true,
    "noImplicitAny": false,
    "types": [
      "meteor-typings"
    ]
  },
  "exclude": [
    "node_modules"
  ],
  "compileOnSave": false,
  "atom": {
    "rewriteTsconfig": false
  }
}

project package.json

{
    "name": "Nexxdeli-App",
    "version": "0.0.1",
    "author": "MRHASAN/ptc-gps.de",
    "homepage": "http://ptc-gps.de",
    "private": true,
    "scripts": {
        "clean": "ionic-app-scripts clean",
        "build": "ionic-app-scripts build",
        "lint": "ionic-app-scripts lint",
        "ionic:build": "ionic-app-scripts build",
        "ionic:serve": "ionic-app-scripts serve",
        "meteor-client:bundle": "meteor-client bundle -s api -c meteor-client.config.json"
    },
    "dependencies": {
        "@angular/common": "4.1.3",
        "@angular/compiler": "4.1.3",
        "@angular/compiler-cli": "4.1.3",
        "@angular/core": "4.1.3",
        "@angular/forms": "4.1.3",
        "@angular/http": "4.1.3",
        "@angular/platform-browser": "4.1.3",
        "@angular/platform-browser-dynamic": "4.1.3",
        "@ionic-native/core": "3.12.1",
        "@ionic-native/splash-screen": "3.12.1",
        "@ionic-native/status-bar": "3.12.1",
        "@ionic/storage": "^2.0.1",
        "@ngui/map": "^0.18.5",
        "@types/googlemaps": "^3.26.20",
        "aws-sdk": "^2.95.0",
        "babel-runtime": "^6.23.0",
        "cordova-android": "^6.2.3",
        "cordova-browser": "^4.1.0",
        "cordova-plugin-console": "^1.0.7",
        "cordova-plugin-device": "^1.1.6",
        "cordova-plugin-fcm": "^2.1.2",
        "cordova-plugin-splashscreen": "^4.0.3",
        "cordova-plugin-statusbar": "^2.2.3",
        "cordova-plugin-whitelist": "^1.3.2",
        "cordova-sqlite-storage": "^2.0.4",
        "ionic-angular": "3.5.0",
        "ionic-plugin-keyboard": "^2.2.1",
        "ionicons": "3.0.0",
        "meteor-node-stubs": "^0.2.11",
        "meteor-rxjs": "^0.4.7",
        "rxjs": "5.4.0",
        "sw-toolbox": "3.6.0",
        "zone.js": "0.8.12"
    },
    "devDependencies": {
        "@ionic/app-scripts": "2.0.1",
        "@ionic/cli-plugin-cordova": "1.6.2",
        "@ionic/cli-plugin-ionic-angular": "1.4.1",
        "@types/meteor": "^1.4.2",
        "@types/underscore": "^1.8.3",
        "ionic": "3.7.0",
        "meteor-typings": "^1.4.1",
        "tmp": "0.0.31",
        "ts-helpers": "^1.1.2",
        "typescript": "2.3.4",
        "typescript-extends": "^1.0.1"
    },
    "description": "Nexxdeli Ionic project",
    "config": {
        "ionic_webpack": "./webpack.config.js"
    },
    "cordova": {
        "plugins": {
            "cordova-plugin-console": {},
            "cordova-plugin-device": {},
            "cordova-plugin-splashscreen": {},
            "cordova-plugin-statusbar": {},
            "cordova-plugin-whitelist": {},
            "ionic-plugin-keyboard": {},
            "cordova-plugin-fcm": {},
            "cordova-sqlite-storage": {}
        },
        "platforms": [
            "android",
            "browser"
        ]
    }
}

Error Output

$ ionic cordova build android --prod --release
Running app-scripts build: --build --prod --iscordovaserve --nobrowser

[14:11:24]  build prod started ... 
[14:11:24]  clean started ... 
[14:11:24]  clean finished in 2 ms 
[14:11:24]  copy started ... 
[14:11:24]  ngc started ... 
[14:11:35]  ngc finished in 11.36 s 
[14:11:35]  preprocess started ... 
[14:11:35]  deeplinks started ... 
[14:11:36]  deeplinks finished in 726 ms 
[14:11:36]  optimization started ... 
[14:11:36]  copy finished in 12.35 s 
[WARN] Error occurred during command execution from a CLI plugin (@ionic/cli-plugin-cordova).
Error: ./src/components/product-categories/product-categories.component.js
Module not found: Error: Can't resolve 'api/collections' in '/home/noshu/code/ptc-gps/nexxdeli-mobile/src/components/product-categories'
resolve 'api/collections' in '/home/noshu/code/ptc-gps/nexxdeli-mobile/src/components/product-categories'
  Parsed request is a module
  using description file: /home/noshu/code/ptc-gps/nexxdeli-mobile/package.json (relative path: ./src/components/product-categories)
    Field 'browser' doesn't contain a valid alias configuration
  after using description file: /home/noshu/code/ptc-gps/nexxdeli-mobile/package.json (relative path: ./src/components/product-categories)
    resolve as module
      /home/noshu/code/ptc-gps/nexxdeli-mobile/src/components/product-categories/node_modules doesn't exist or is not a directory
      /home/noshu/code/ptc-gps/nexxdeli-mobile/src/components/node_modules doesn't exist or is not a directory
      /home/noshu/code/ptc-gps/nexxdeli-mobile/src/node_modules doesn't exist or is not a directory
      /home/noshu/code/ptc-gps/node_modules doesn't exist or is not a directory
      /home/noshu/code/node_modules doesn't exist or is not a directory
      /home/noshu/node_modules doesn't exist or is not a directory
      /home/node_modules doesn't exist or is not a directory
      /node_modules doesn't exist or is not a directory
      looking for modules in /home/noshu/code/ptc-gps/nexxdeli-mobile/node_modules
        using description file: /home/noshu/code/ptc-gps/nexxdeli-mobile/package.json (relative path: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
        after using description file: /home/noshu/code/ptc-gps/nexxdeli-mobile/package.json (relative path: ./node_modules)
          using description file: /home/noshu/code/ptc-gps/nexxdeli-mobile/package.json (relative path: ./node_modules/api/collections)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /home/noshu/code/ptc-gps/nexxdeli-mobile/node_modules/api/collections doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /home/noshu/code/ptc-gps/nexxdeli-mobile/node_modules/api/collections.js doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              /home/noshu/code/ptc-gps/nexxdeli-mobile/node_modules/api/collections.ts doesn't exist
            as directory
              /home/noshu/code/ptc-gps/nexxdeli-mobile/node_modules/api/collections doesn't exist
[/home/noshu/code/ptc-gps/nexxdeli-mobile/src/components/product-categories/node_modules]
[/home/noshu/code/ptc-gps/nexxdeli-mobile/src/components/node_modules]
[/home/noshu/code/ptc-gps/nexxdeli-mobile/src/node_modules]
[/home/noshu/code/ptc-gps/node_modules]
[/home/noshu/code/node_modules]
[/home/noshu/node_modules]
[/home/node_modules]
[/node_modules]
[/home/noshu/code/ptc-gps/nexxdeli-mobile/node_modules/api/collections]
[/home/noshu/code/ptc-gps/nexxdeli-mobile/node_modules/api/collections.js]
[/home/noshu/code/ptc-gps/nexxdeli-mobile/node_modules/api/collections.ts]
[/home/noshu/code/ptc-gps/nexxdeli-mobile/node_modules/api/collections]
 @ ./src/components/product-categories/product-categories.component.js 5:20-46
 @ ./src/components/product-categories/product-categories.component.ngfactory.js
 @ ./src/app/app.module.ngfactory.js
 @ ./src/app/main.ts,./src/components/single-product/single-product.component.js
Module not found: Error: Can't resolve 'api/collections' in '/home/noshu/code/ptc-gps/nexxdeli-mobile/src/components/single-product'
resolve 'api/collections' in '/home/noshu/code/ptc-gps/nexxdeli-mobile/src/components/single-product'
  Parsed request is a module
  using description file: /home/noshu/code/ptc-gps/nexxdeli-mobile/package.json (relative path: ./src/components/single-product)
    Field 'browser' doesn't contain a valid alias configuration
  after using description file: /home/noshu/code/ptc-gps/nexxdeli-mobile/package.json (relative path: ./src/components/single-product)
    resolve as module
      /home/noshu/code/ptc-gps/nexxdeli-mobile/src/components/single-product/node_modules doesn't exist or is not a directory
      /home/noshu/code/ptc-gps/nexxdeli-mobile/src/components/node_modules doesn't exist or is not a directory
      /home/noshu/code/ptc-gps/nexxdeli-mobile/src/node_modules doesn't exist or is not a directory
      /home/noshu/code/ptc-gps/node_modules doesn't exist or is not a directory
      /home/noshu/code/node_modules doesn't exist or is not a directory
      /home/noshu/node_modules doesn't exist or is not a directory
      /home/node_modules doesn't exist or is not a directory
      /node_modules doesn't exist or is not a directory
      looking for modules in /home/noshu/code/ptc-gps/nexxdeli-mobile/node_modules
        using description file: /home/noshu/code/ptc-gps/nexxdeli-mobile/package.json (relative path: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
        after using description file: /home/noshu/code/ptc-gps/nexxdeli-mobile/package.json (relative path: ./node_modules)
          using description file: /home/noshu/code/ptc-gps/nexxdeli-mobile/package.json (relative path: ./node_modules/api/collections)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /home/noshu/code/ptc-gps/nexxdeli-mobile/node_modules/api/collections doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /home/noshu/code/ptc-gps/nexxdeli-mobile/node_modules/api/collections.js doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              /home/noshu/code/ptc-gps/nexxdeli-mobile/node_modules/api/collections.ts doesn't exist
            as directory
              /home/noshu/code/ptc-gps/nexxdeli-mobile/node_modules/api/collections doesn't exist
[/home/noshu/code/ptc-gps/nexxdeli-mobile/src/components/single-product/node_modules]
[/home/noshu/code/ptc-gps/nexxdeli-mobile/src/components/node_modules]
[/home/noshu/code/ptc-gps/nexxdeli-mobile/src/node_modules]
[/home/noshu/code/ptc-gps/node_modules]
[/home/noshu/code/node_modules]
[/home/noshu/node_modules]
[/home/node_modules]
[/node_modules]
[/home/noshu/code/ptc-gps/nexxdeli-mobile/node_modules/api/collections]
[/home/noshu/code/ptc-gps/nexxdeli-mobile/node_modules/api/collections.js]
[/home/noshu/code/ptc-gps/nexxdeli-mobile/node_modules/api/collections.ts]
[/home/noshu/code/ptc-gps/nexxdeli-mobile/node_modules/api/collections]
 @ ./src/components/single-product/single-product.component.js 7:20-46
 @ ./src/components/single-product/single-product.component.ngfactory.js
 @ ./src/app/app.module.ngfactory.js
 @ ./src/app/main.ts,./src/components/user-order-list/user-order-list.component.js

error output continues like this

Note

  • ionic run and lab commands run okay
@darkbasic
Copy link
Contributor

Hi, thanks for reporting.
It's IonicCLI related, so let's track it there: Urigo/Ionic2CLI-Meteor-WhatsApp#113

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants