Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build error when trying to build with webpack support for Android #42

Closed
andy-tai opened this issue Feb 19, 2017 · 16 comments
Closed

build error when trying to build with webpack support for Android #42

andy-tai opened this issue Feb 19, 2017 · 16 comments

Comments

@andy-tai
Copy link

andy-tai commented Feb 19, 2017

(NS 2.5)
Take the Nativescript-Angular demo program in the pull request #41; cd to the demo program demo_angular's directory, run it to ensure it runs normally without webpack, and try to add the web pack plugin as instructed here http://docs.nativescript.org/angular/tooling/bundling-with-webpack.html:

npm install --save-dev nativescript-dev-webpack

and then when trying to test the Android bundle,
npm run start-android-bundle

that would fail with these error:

ERROR in Error encountered resolving symbol values statically. Reference to a non-exported class L. Conside
r exporting the class (position 15:1 in the original .ts file), resolving symbol NativeScriptI18nModule in
/run/media/atai/922aaf05-07b2-4f6a-927a-5456003f94c1/software/nativescript/nativescript-i18n.git/demo_angular/node_modules/nativescript-i18n/angular.ts

@andy-tai andy-tai changed the title webpack support on Android build rror when trying to build with webpack support for Android Feb 19, 2017
@andy-tai andy-tai changed the title build rror when trying to build with webpack support for Android build error when trying to build with webpack support for Android Feb 19, 2017
@rborn
Copy link
Collaborator

rborn commented Feb 21, 2017

@andy-tai could you try exporting the L class in angular.ts, something like export class L implements PipeTransform ?

@rborn
Copy link
Collaborator

rborn commented Mar 6, 2017

@andy-tai any news on this?

@andy-tai
Copy link
Author

andy-tai commented Mar 6, 2017

oh, sorry I missed that. I will try it today

@andy-tai
Copy link
Author

andy-tai commented Mar 8, 2017

OK that would allow the build process to pass that error, to the next one:

$ npm run start-android-bundle

> @ start-android-bundle /run/media/atai/922aaf05-07b2-4f6a-927a-5456003f94c1/software/nativescript/nativescript-i18n.git/demo_angular
> npm run ns-bundle --android --start-app


> @ ns-bundle /run/media/atai/922aaf05-07b2-4f6a-927a-5456003f94c1/software/nativescript/nativescript-i18n.git/demo_angular
> ns-bundle

Running webpack for android...
/run/media/atai/922aaf05-07b2-4f6a-927a-5456003f94c1/software/nativescript/nativescript-i18n.git/demo_angular/node_modules/typescript/lib/typescript.js:14552
            var sourceFile = new SourceFileConstructor(261 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length);
                                                                                                            ^

TypeError: Cannot read property 'length' of undefined
    at createSourceFile (/run/media/atai/922aaf05-07b2-4f6a-927a-5456003f94c1/software/nativescript/nativescript-i18n.git/demo_angular/node_modules/typescript/lib/typescript.js:14552:109)
    at parseSourceFileWorker (/run/media/atai/922aaf05-07b2-4f6a-927a-5456003f94c1/software/nativescript/nativescript-i18n.git/demo_angular/node_modules/typescript/lib/typescript.js:14484:26)
    at Object.parseSourceFile (/run/media/atai/922aaf05-07b2-4f6a-927a-5456003f94c1/software/nativescript/nativescript-i18n.git/demo_angular/node_modules/typescript/lib/typescript.js:14433:26)
    at Object.createSourceFile (/run/media/atai/922aaf05-07b2-4f6a-927a-5456003f94c1/software/nativescript/nativescript-i18n.git/demo_angular/node_modules/typescript/lib/typescript.js:14288:29)
    at WebpackCompilerHost.getSourceFile (/run/media/atai/922aaf05-07b2-4f6a-927a-5456003f94c1/software/nativescript/nativescript-i18n.git/demo_angular/node_modules/@ngtools/webpack/src/compiler_host.js:209:27)
    at findSourceFile (/run/media/atai/922aaf05-07b2-4f6a-927a-5456003f94c1/software/nativescript/nativescript-i18n.git/demo_angular/node_modules/typescript/lib/typescript.js:63453:29)
    at processSourceFile (/run/media/atai/922aaf05-07b2-4f6a-927a-5456003f94c1/software/nativescript/nativescript-i18n.git/demo_angular/node_modules/typescript/lib/typescript.js:63384:27)
    at /run/media/atai/922aaf05-07b2-4f6a-927a-5456003f94c1/software/nativescript/nativescript-i18n.git/demo_angular/node_modules/typescript/lib/typescript.js:63494:17
    at Object.forEach (/run/media/atai/922aaf05-07b2-4f6a-927a-5456003f94c1/software/nativescript/nativescript-i18n.git/demo_angular/node_modules/typescript/lib/typescript.js:1293:30)
    at processReferencedFiles (/run/media/atai/922aaf05-07b2-4f6a-927a-5456003f94c1/software/nativescript/nativescript-i18n.git/demo_angular/node_modules/typescript/lib/typescript.js:63492:16)
    at findSourceFile (/run/media/atai/922aaf05-07b2-4f6a-927a-5456003f94c1/software/nativescript/nativescript-i18n.git/demo_angular/node_modules/typescript/lib/typescript.js:63477:21)
    at processSourceFile (/run/media/atai/922aaf05-07b2-4f6a-927a-5456003f94c1/software/nativescript/nativescript-i18n.git/demo_angular/node_modules/typescript/lib/typescript.js:63384:27)
    at processRootFile (/run/media/atai/922aaf05-07b2-4f6a-927a-5456003f94c1/software/nativescript/nativescript-i18n.git/demo_angular/node_modules/typescript/lib/typescript.js:63271:13)
    at /run/media/atai/922aaf05-07b2-4f6a-927a-5456003f94c1/software/nativescript/nativescript-i18n.git/demo_angular/node_modules/typescript/lib/typescript.js:62620:60
    at Object.forEach (/run/media/atai/922aaf05-07b2-4f6a-927a-5456003f94c1/software/nativescript/nativescript-i18n.git/demo_angular/node_modules/typescript/lib/typescript.js:1293:30)
    at Object.createProgram (/run/media/atai/922aaf05-07b2-4f6a-927a-5456003f94c1/software/nativescript/nativescript-i18n.git/demo_angular/node_modules/typescript/lib/typescript.js:62620:16)
child process exited with code 1


@rborn
Copy link
Collaborator

rborn commented Mar 8, 2017

@andy-tai Ugh, nasty. I'll try to take a look but I'm pretty busy this month 😞

@masseelch
Copy link

masseelch commented Apr 16, 2017

Hey there,

i had the same problem as @andy-tai and a google search brought me here. I can confirm that exporting the Lclass does fix the problem.

@andy-tai The error you got after exporting the L class occures, when you built the app once without webpack. If you pull in webpack afterwards you need to either clear the cache or get rid of the platforms folder completely and redo the build. It then succeeds without a problem.

@rborn If exporting the Lclass is save for the non-webpack builds, it seems to fix the problems with webpack.

Regards,
MasseElch

@rborn
Copy link
Collaborator

rborn commented May 5, 2017

@andy-tai @masseelch could you check this branch please.
When I build the demo app with webpack the process doesn't show any error, however there are 2 warnings related to the css and the app displays an empty screen.

Thank you.

@masseelch
Copy link

masseelch commented May 6, 2017

@rborn Im quite busy at the moment but i will try to take a look in the next week.

@masseelch
Copy link

masseelch commented May 6, 2017

@rborn I had some spare time and tested the suggested branch. I still get the same error as reported by @andy-tai:

ERROR in Error encountered resolving symbol values statically. Reference to a non-exported class L. Consider exporting the class (position 15:1 in the original .ts file), resolving symbol NativeScriptI18nModule in [...]/node_modules/nativescript-i18n/angular.ts

Exporting the Lclass does NOT fix the issue any more like it did before. The following error does occur.

ERROR in [...]/node_modules/nativescript-i18n/angular.ts (20,23): Property 'L' does not exist on type 'Global'.

However, this seems to be related to #47.

Regards.

@kssfilo
Copy link
Contributor

kssfilo commented May 12, 2017

@masseelch @rborn

"Property 'L' does not exist on type 'Global'..." has been fixed by following change (Commit: 34fad7d)

-        return global.L(value, ...more);
 +        return application.getResources().L(value, ...more);

Try #49 's update.

I checked @andy-tai 's error is same as #49 's error. So It can be closed, I think.

@rborn rborn closed this as completed May 12, 2017
@andy-tai
Copy link
Author

sorry I don't have time now to test this but thanks for fixing the issue and testing the fix!

@ludcila
Copy link

ludcila commented May 22, 2017

Hi all, I am using tns 2.5 and adding export solves the problem. I am not familiar with how releases work, but would it be possible to have a version, let's say 0.1.7, which fixes just this issue by adding export and still works with tns 2.5? It would be greatly appreciated. Otherwise, could you please give me some advice regarding how I should handle this on my side?

Thanks!
Lucía

@rborn
Copy link
Collaborator

rborn commented May 23, 2017

@ludcila the current version has the export already. Am I understanding wrong?

@ludcila
Copy link

ludcila commented May 23, 2017

Hi @rborn, I have problems making the latest version work with Nativescript 2.5. Version 0.1.6 works fine, but I have to manually add the export.

Is the latest version supposed to work also with older versions of Nativescript? I cannot move my application to 3.0 yet because I need other issues to be solved first.

@rborn
Copy link
Collaborator

rborn commented May 23, 2017

@ludcila I'm sorry but you will need to make a fork, roll back to 0.1.6 and add the export yourself for 2.5
I'm not able to support the old versions of Nativescript 😢

@ludcila
Copy link

ludcila commented May 23, 2017

I see, thanks for clarifying :)

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

No branches or pull requests

5 participants