Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Webpack build issue with tns-platform-declarations #101

Closed
kvindascr opened this issue Mar 12, 2017 · 7 comments · Fixed by #120 or NativeScript/nativescript-intl#11
Closed

Webpack build issue with tns-platform-declarations #101

kvindascr opened this issue Mar 12, 2017 · 7 comments · Fixed by #120 or NativeScript/nativescript-intl#11

Comments

@kvindascr
Copy link

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
Copy link
Contributor

sis0k0 commented Mar 13, 2017

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
Copy link
Author

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:

  • Typescript: 2.0.10
  • ngtools?? What exactly do you mean by ng-tools. I looked out in my node_modules but I have no package starting with ng-, not anyone of the described in your link.

Thanks.

@sis0k0
Copy link
Contributor

sis0k0 commented Mar 16, 2017

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
Copy link
Contributor

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
Copy link

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

@ishitatsuyuki
Copy link

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
Copy link

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

sis0k0 added a commit that referenced this issue Apr 17, 2017
The "exclude" property isn't properly inherited from the base
configuration ("tsconfig.json") so we need to explicitly specify it.
This caused the angular compiler to try to parse the `platforms` folder
and eventually fail.

fixes #101
sis0k0 added a commit to NativeScript/nativescript-intl that referenced this issue Apr 18, 2017
sis0k0 added a commit to NativeScript/nativescript-intl that referenced this issue Apr 18, 2017
sis0k0 added a commit that referenced this issue Apr 18, 2017
The "exclude" property isn't properly inherited from the base
configuration ("tsconfig.json") so we need to explicitly specify it.
This caused the angular compiler to try to parse the `platforms` folder
and eventually fail.

fixes #101
sis0k0 added a commit that referenced this issue Apr 18, 2017
The "exclude" property isn't properly inherited from the base
configuration ("tsconfig.json") so we need to explicitly specify it.
This caused the angular compiler to try to parse the `platforms` folder
and eventually fail.

fixes #101
sis0k0 added a commit that referenced this issue Apr 19, 2017
The "exclude" property isn't properly inherited from the base
configuration ("tsconfig.json") so we need to explicitly specify it.
This caused the angular compiler to try to parse the `platforms` folder
and eventually fail.

fixes #101
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
5 participants