NativeScript / nativescript-dev-webpack

A package to help with webpacking NativeScript apps.
Apache License 2.0
97 stars 49 forks source link

Webpack build issue with tns-platform-declarations #101

Closed kvindascr closed 7 years ago

kvindascr commented 7 years ago

When installed tns-platform-declarations, webpack generate the following error:

typescript.js-createSourceFile: /Users/kvindas/Development/js-project/workride-app/platforms/android/build/intermediates/assets/F0F1F2F3F4F5F6F7F8/debug/app/tns_modules/node_modules/tns-platform-declarations/ios.d.ts
/Users/kvindas/Development/js-project/workride-app/node_modules/typescript/lib/typescript.js:8981
            var sourceFile = new SourceFileConstructor(256 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length);
                                                                                                            ^

TypeError: Cannot read property 'length' of undefined
    at createSourceFile (/Users/kvindas/Development/js-project/workride-app/node_modules/typescript/lib/typescript.js:8981:109)
sis0k0 commented 7 years ago

Try deleting the platforms folder. From the provided log, I understand you are building for android. Also which versions of typescipt and @ngtools do you use?

kvindascr commented 7 years ago

Hello,

Sis0k0, I was really building IOS. In fact I needed to delete android platform at somepoint because for some reason Android issues were getting in between when building IOS.

Regarding versions they are:

Thanks.

sis0k0 commented 7 years ago

You should have a dev dependancy of @ngtools/webpack if you are using the nativescript-dev-webpack plugin. Also try deleting the whole platforms folder and rebuild with npm run build-ios-bundle. Hope that helps! If it does not, please send us a project where you can reproduce the error.

DickSmith commented 7 years ago

I usually see this error if I have run a non-webpack tns prepare/run/build/debug ... before I run the webpack command. Usually I run tns platform remove ... for both Android and iOS. Strangely, you need to remove it for both, so if I have run and Android build only, and then do an iOS webpack, the iOS webpack will fail and vice-versa.

I don't believe it's related to the tns-platform-declarations, as I had those included in the project before and this issue only popped up with one of the updates a few weeks back.

All my dependencies are up to date with the latest versions ( including all the angular/webpack/nativescript packages, etc. ) with the exception of: rxjs: 5.0.3 typescript: 2.1.6

Rachnerd commented 7 years ago

I got rid of this error by removing platforms and not executing the "run" command before bundling. Weird. @DickSmith Thanks!

ishitatsuyuki commented 7 years ago

This is quite annoying. When I debugged it, it's clearly related to the tns-platform-declarations missing in the platforms. (The same file as the OP has)

I suspect this is some hook malfunctioning?

ishitatsuyuki commented 7 years ago

The suspicious folder is platforms/android/src/main/assets/app/tns_modules. Maybe they are not cleaned across builds?