ATTENTION: Upcoming Ionic 2 Starter Changes

Hello Ionites! Just want to give the community a heads up about changes that are going to be happening to Ionic 2 projects. None of these have happened yet, but we want to give everyone a word of warning before everything breaks and the world ends.

  • This has been done :rocket: The first one will be moving from the ionic-framework package name to ionic-angular. We will still publish ionic-framework for the next release, but the starters will move to ionic-angular once the CLI has been updated to support it. THIS WILL BREAK ALL THE THINGS, so if youā€™re having issues please update your CLI to the latest beta: npm install -g ionic@beta.

  • This has been done :rocket: We will be moving the build (transpiling, bundling, Sass compilation) out of the CLI into a gulpfile. Everything will Just Work :tm: by default, but it will now be much easier to extend your build.

  • This has been done :rocket: We will most likely be moving away from webpack as the default bundler in favor of Browserify. Webpack fans, donā€™t fret, with the build being Gulp based, using webpack is as easy as swapping out the bundle task (jspm/systemJS we got you too :ok_hand:) . Eventually, this will be configurable.

We love you and love your feedback, so let us know if you have any questions or concerns! :heart:

12 Likes

Hi, iā€™m really interested in knowing what drives the decision to change Webpack in favour of Browserify, for the ones like me that has customized the build process of webpack with a few plugins for minification and deduplication what would be the benefit of Browerify instead of Webpack?

1 Like

The move to Browserify is mostly for new users, as the learning curve of webpack is fairly high. If you have a highly customized webpack build and feel comfortable using the tool I would suggest sticking with it.

Both tools are great and are mainly a matter of personal preference. Browserify is good for people who prefer code over configuration (similar to Gulp vs Grunt) and has a very similar workflow to using Gulp. Webpack can do pretty much anything youā€™d ever need to do for an app, and is extremely powerful, but at the cost of having a fairly complicated configuration file, which can be daunting for new users.

Anecdotally, it took me about 15 minutes to get the conference app working with browserify, whereas working my way through wiring up webpack the first time took me over an hour. I have to say though, the more I use webpack, the more I appreciate everything it does, so I definitely donā€™t want to discourage people from using it.

I should add as well, that the startup time required for webpack is nonexistent for Ionic starters because they come with working webpack configs. In my case, I was writing one from scratch :slightly_smiling:

We want Ionic to make app development as easy and straightforward as possible, and webpack, although quite powerful, doesnā€™t align as well with that goal at the moment.

For a nice discussion on both tools, Iā€™d recommend listening to the React Podcast on the them: http://reactpodcast.com/2015/06/webpack-vs-browserify/.

Hello Houston i have a problem ā€œFailed at the ionic@2.0.0-beta.18 postinstall script ā€˜node lib/tasks/postinstallā€™.ā€ and i have node and npm updated.

Thanks for the heads up Tim.

1 Like

Hi Tim, trying to update, getting this:
gyp ERR! configure error

Thanks.

Uh oh, looks like a few people are having issues with postinstall scripts. If anyone is getting install errors, could you please open an issue at https://github.com/driftyco/ionic-cli/issues and weā€™ll see if we can get things sorted, thanks!

Hi @tim, open in https://github.com/driftyco/ionic-cli/issues/800.
Thnks!

1 Like

Awesome - love that you guys gave advanced warning of this change. Can Ionitron tweet out a link to posts like this, too? I donā€™t visit the forums as often as I probably should.

Thanks,
Dan

Yeah oversight on my part, I tweeted it but should have had the Ionic account do so as well, sorry about that!

If this means we can build without having to serve or generate, Iā€™m very content :slightly_smiling:

I am very happy that you have chosen to replace Webpack with Browserify. Your reasoning is spot on, and exactly what I also encountered. Webpack is quite complex to get started with, whereas Browserify is much simpler.

Hi Tim,

Looked at various starter projects and they still seems to use webpack.config. They do have your new gulpfile but it makes use of webpack.

Is there an example/starter that shows how to use browserify ?

Regards & thanks
Kapil

Hi Tim. Hereā€™s some feedback :slightly_smiling:

  1. I just created a new project using ionic@2.0.0-beta.19 using: ionic start MyProject tabs --v2 --ts
  2. I then tried ionic serve, and everything worked as expected.
  3. At this point, I submitted and pushed my project skeleton, and pulled it from another git client, to make sure that everything will work for my team members.
  4. In my new git client, I typed ionic serve, but this time I received a blank page, and a 404 for app.bundle.js in my console.
  5. Looking at the project files, Iā€™ve noticed that the www/build folder is missing (by design according to my .gitignore)

So the problem is that ionic serve doesnā€™t detect the missing build folder, and just opens the browser, instead of rebuilding my ts files etc.

Thanks,
Boaz

I just wanted to double check with you.

I have manage to upgrade to beta.2 from older version. Iā€™m still using webdev (I do know gulp), but I prefer to continue on using webdev.

Do I have to do any other changes regarding old webdev?

var path = require('path');


module.exports = {
  entry: [
    path.normalize('es6-shim/es6-shim.min'),
    'reflect-metadata',
    path.normalize('zone.js/dist/zone-microtask'),
    path.resolve('app/app')
  ],
  output: {
    path: path.resolve('www/build/js'),
    filename: 'app.bundle.js',
    pathinfo: false // show module paths in the bundle, handy for debugging
  },
  module: {
    loaders: [
      {
        test: /\.ts$/,
        loader: 'awesome-typescript',
        query: {
          'doTypeCheck': true
        },
        include: path.resolve('app'),
        exclude: /node_modules/
      },
      {
        test: /\.js$/,
        include: path.resolve('node_modules/angular2'),
        loader: 'strip-sourcemap'
      }
    ],
    noParse: [
      /es6-shim/,
      /reflect-metadata/,
      /zone\.js(\/|\\)dist(\/|\\)zone-microtask/
    ]
  },
  resolve: {
    root: [
      'app'
    ],
    alias: {
      'angular2': path.resolve('node_modules/angular2')
    },
    extensions: ["", ".js", ".ts"]
  }
};

Browserify hasnā€™t been rolled out quite yet, weā€™re trying to change things incrementally so updating existing projects isnā€™t a total nightmare.

I would guess you need to run npm install, since the CLI checks for Ionic 2 in node_modules to know if it should build on serve or not (even if it did know, the build would fail because you hadnā€™t npm installā€™ed yet :slightly_smiling: )

I feel like this is a pretty common problem (I do it all the time and then think Iā€™ve broken the CLI) so if possible in the future the CLI should try and warn you if you need to run npm install.[quote=ā€œibasit, post:17, topic:45058ā€]
I just wanted to double check with you.

I have manage to upgrade to beta.2 from older version. Iā€™m still using webdev (I do know gulp), but I prefer to continue on using webdev.

Do I have to do any other changes regarding old webdev?
[/quote]

Looks fine to me :thumbsup: As a reference you can take a look at the current version of configuration files in the conference app.

npm install did fix the issue.

Thanks for the fast turnaround!

1 Like

Would it be possible to override the build step via a configuration setting in ionic.config.js? That way if youā€™ve already got a set build script (e.g. webpack or npm scripts) you could provide the command in the config file that ionic-cli should use. ionic-cli could then ionic serve as normal. The defaults could be whatever you end up thinking should be default whether its gulp or browserify but It would nice to have fit into an existing build process.

jimitndiaye - the gulp process specifies what is being done in the build from the way I
understand the current v2 build process steps. Gulp is really easy to configure and has its
own config file you should be able to update/ mod the build tool setup - ( browerify/webpack/ec2jsā€¦).