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

bundling worker: "TypeError: Cannot read property 'newLine' of undefined" #139

Closed
m-abs opened this issue May 2, 2017 · 6 comments
Closed
Labels

Comments

@m-abs
Copy link

m-abs commented May 2, 2017

I'm trying to bundle a worker in our project, but I keep getting this error:

    ERROR in ../~/nativescript-dev-webpack/tns-aot-loader.js!../~/@ngtools/webpack/src!./worker.ts
    Module build failed: TypeError: Cannot read property 'newLine' of undefined
        at Object.getNewLineCharacter (/home/mabs/project/ns-debugging/bundle-worker/node_modules/typescript/lib/typescript.js:9426:20)
        at Object.createCompilerHost (/home/mabs/project/ns-debugging/bundle-worker/node_modules/typescript/lib/typescript.js:62475:26)
        at Object.ngcLoader (/home/mabs/project/ns-debugging/bundle-worker/node_modules/@ngtools/webpack/src/loader.js:338:33)

I've created a demo project here:
https://github.com/m-abs/ns-debugging/tree/master/bundle-worker

It's a very simple worker as you can see here: https://github.com/m-abs/ns-debugging/blob/master/bundle-worker/app/worker.ts

I'm using @triniwiz's worker-loader and test for global.TNS_WEBPACK as suggested in #86 (comment)
Like this: https://github.com/m-abs/ns-debugging/blob/master/bundle-worker/app/app.module.ts#L32-L48

What am I doing wrong?

@m-abs
Copy link
Author

m-abs commented May 3, 2017

Update:
If I transpile the worker's TS to JS myself, the worker runs as expected.
But resulting [hash].worker.js is rather large after I had to import 'global' but it's progress. 👍

I think it would be better if I could get webpack to transpile my worker.ts file for me.
Is this possible?

@hypery2k
Copy link

any workarounds? I'm getting this issue too

@m-abs
Copy link
Author

m-abs commented Jul 14, 2017

Only the one I mentioned :)

If you use nativescript-dev-typescript you might be able to get that to transpile it by running tns prepare android or tns prepare ios before running the bundle process.

@hypery2k
Copy link

doesn't for me with TNS3

@m-abs
Copy link
Author

m-abs commented Aug 10, 2017

What if you require the worker from vendor.ts?

Sent from my OnePlus ONEPLUS A3003 using FastHub

@sis0k0 sis0k0 added the backlog label Aug 21, 2018
@m-abs m-abs closed this as completed Jan 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants