ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

gulp build issues

Open ratt opened this issue 10 years ago • 9 comments

Upgrading to beta10 and gulp is not building the app.bundle.js If we run the exact same code in beta9 the file is correctly created.

I have traced it to do with "ionic-gulp-browserify-typescript"

If there is an error in your typescript EG: TypeScript error: /app/pages/home/home.ts(25,42): Error TS2304: Cannot find name 'cordova'.

We are using the current ionic-native file plugin so we have to access "cordova.file.applicationDirectory" directly.

So when running ionic serve, no error seems to be returned apart from the warnings generated by the TypeScript error: (these have always been there prior to beta 10) the JS is not correctly compiled to /build/js/app.bundle.js

If we open "ionic-gulp-browserify-typescript/index.js" and comment line 29

onError: function(err){
    console.error(err.toString());
//    this.emit('end');
},

The app still shows the errors on the console but correctly creates the /build/js/app.bundle.js

ratt avatar Jun 28 '16 09:06 ratt

I'm having the same issue. Simple test:

  1. Create a new ionic 2 project using —TS option
  2. Add following lines to app/pages/home/home.ts:
  ionViewWillEnter() {
  document.getElementsByTagName('ion-navbar-section')[0].style.display = 'none';
}
  1. Serve app via ionic serve

==> TypeScript complains about: Error TS2339: Property 'style' does not exist on type 'Element'. and /build/js/app.bundle.js is not generated.

Before the update the app.bundle.js was still generated (and working) even though TS is sometimes complaining about some stuff.

davidruisinger avatar Jun 28 '16 10:06 davidruisinger

@ratt use declare var cordova: any; above your first '@' element

guillenotfound avatar Jun 28 '16 10:06 guillenotfound

@ZiFFeL1992 Thanks, The issue still exists with other aspects of code as per @flavordaaave comments. Here is an example

let video = document.querySelectorAll('video');
        if(video){
            for(let x =0; x < video.length; x++){
                video[x].pause();
            }
        }
    }

Which generates the following TypeScript error: ..../app/pages/engine/base-page.ts(456,26): Error TS2339: Property 'pause' does not exist on type 'Element'.

on Beta 9, these errors were simply reported, now on beta 10 it seems to be enforced?

ratt avatar Jun 28 '16 10:06 ratt

@ratt Try let video: any = ...

guillenotfound avatar Jun 28 '16 10:06 guillenotfound

@ZiFFeL1992 The problem is that the build process fails with any TypeScript "error" and in my code I still have a lot of them because sometimes TypeScript just not works as expected or I don't have all the Definitions for a library I'm using.

davidruisinger avatar Jun 28 '16 11:06 davidruisinger

I can confirm if we clean up all Typescript errors, and put external libraries in the typings/index.d.ts

EG:

declare var config: any;

// Cordova
declare var cordova: any;

// lowdash
declare var _: any;

Then the app compiles again correctly

ratt avatar Jun 28 '16 11:06 ratt

Thanks @ZiFFeL1992

I think perhaps a better way to explain this issue or references on how to fix may help new ionic 2/typescript devs

ratt avatar Jun 28 '16 11:06 ratt

Hello all! While the build is actually working as expected right now we are discussing this to see the best way for our build to handle typescript errors. I will keep this issue open so that i can update you guys on what we come up with. Thanks for using Ionic!

jgw96 avatar Jun 28 '16 16:06 jgw96

Hello all! At this time we are not planning on making any changes with how this works. Thanks for using Ionic! If anything changes I will reopen this issue.

jgw96 avatar Jun 29 '16 16:06 jgw96