Skip to content
This repository has been archived by the owner on May 1, 2020. It is now read-only.

v0.0.42 Custom Rollup is not working #342

Closed
rodriguesgm opened this issue Nov 9, 2016 · 5 comments
Closed

v0.0.42 Custom Rollup is not working #342

rodriguesgm opened this issue Nov 9, 2016 · 5 comments
Assignees

Comments

@rodriguesgm
Copy link

Short description of the problem:

I'm using a custom rollup config and after the upgrade to v0.0.42 it's not running ionic serve anymore. I'm getting "rollup failed: Could not resolve './app.module' from ...app\src\app\main.dev.ts".
My custom rollup.config is just to add env variables into my app. I got the idea from here ionic-team/ionic-framework#8370
If, there is a better way to do it or a way to do it with webpack, it would be good to know.

What behavior are you expecting?

After the upgrade to the newest version, it should still work.

This is my rollup.config.j

var nodeResolve = require('rollup-plugin-node-resolve');
var commonjs = require('rollup-plugin-commonjs');
var globals = require('rollup-plugin-node-globals');
var builtins = require('rollup-plugin-node-builtins');
var json = require('rollup-plugin-json');
var replace = require('rollup-plugin-replace');
var fs = require('fs');

// https://github.com/rollup/rollup/wiki/JavaScript-API
var rollupConfig = {
  /**
   * entry: The bundle's starting point. This file will
   * be included, along with the minimum necessary code
   * from its dependencies
   */
  entry: '{{SRC}}/app/main.dev.ts',

  /**
   * sourceMap: If true, a separate sourcemap file will
   * be created.
   */
  sourceMap: true,

  /**
   * format: The format of the generated bundle
   */
  format: 'iife',

  /**
   * dest: the output filename for the bundle in the buildDir
   */
  dest: 'main.js',

  /**
   * plugins: Array of plugin objects, or a single plugin object.
   * See https://github.com/rollup/rollup/wiki/Plugins for more info.
   */
  plugins: [
    replace({
      include: 'src/config/index.ts',
      './config': process.env.IONIC_ENV == 'prod' ? './config.prod' : './config.dev',
    }),
    builtins(),
    commonjs(),
    nodeResolve({
      module: true,
      jsnext: true,
      main: true,
      browser: true,
      extensions: ['.js']
    }),
    globals(),
    json()
  ]

};

//check if files actually exist
if (process.env.IONIC_ENV == 'prod') {
  // production mode
  rollupConfig.entry = '{{TMP}}/app/main.prod.ts';
  rollupConfig.sourceMap = false;
  fs.access('src/config/config.prod.ts', fs.F_OK, (err) => {
    if (err) {
      throw err;
    }
  });
} else {
  fs.access('src/config/config.dev.ts', fs.F_OK, (err) => {
    if (err) {
      throw err;
    }
  });
}

module.exports = rollupConfig;

A part of my package.json

  ....
  "scripts": {
   "ionic:build": "ionic-app-scripts build",
   "ionic:serve": "ionic-app-scripts serve",
    "build": "ionic-app-scripts build --dev",
    "watch": "ionic-app-scripts watch",
    "serve:before": "watch",
    "emulate:before": "build",
    "deploy:before": "build",
    "build:before": "build",
    "run:before": "build"
  },
  "config": {
    "ionic_rollup": "./scripts/rollup.config.js",
    "ionic_tslint": "./tslint.json"
  },
  "dependencies": {
   ....
   }
  "devDependencies": {
    "@ionic/app-scripts": "0.0.42",
    "rollup-plugin-replace": "^1.1.1",
    "typescript": "2.0.6"
   }
  ....

Which @ionic/app-scripts version are you using?
v0.0.42

@rodriguesgm
Copy link
Author

I've just saw this open issue, so it's kind of answer a part of my problem ionic-team/ionic-cli#1205

@rodriguesgm
Copy link
Author

ok, so using a custom webpack config for env variables, it worked. But using my custom rollup.config.js, the problem still happens like i described

@danbucholtz
Copy link
Contributor

@rodriguesgm,

I'll take a look.

Thanks,
Dan

@danbucholtz danbucholtz self-assigned this Nov 10, 2016
@danbucholtz
Copy link
Contributor

This should be fixed now. Will be published today as 0.0.43, I'll close it after I publish.

Thanks,
Dan

@danbucholtz
Copy link
Contributor

This is resolved. Please install npm install @ionic/app-scripts@latest.

Thanks,
Dan

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

No branches or pull requests

2 participants