Jump to content

"importScripts" not found


Ingo Chou
 Share

Recommended Posts

importScripts is a dom-feature, existing natively in webworkers (https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers#Importing_scripts_and_libraries)

My assumption is that you are missing the type declaration for importScripts, which should be defined in your tsconfig.json. Try adding "webworker" to "types" in your typescript configuration and see if it helps.

BTW - what TS version are you using?

Link to comment
Share on other sites

{
  "compileOnSave": true,
  "compilerOptions": {
    "experimentalDecorators": true,
    "module": "commonjs",
    "target": "es5",
    "sourceMap": true,
    "lib": [ "dom", "es2015.promise", "es5" ],
    "types": [ "webworker" ]
  }
}

I add "types" like this. Is it right ?

But there is an error:

tsc : error TS2688: Build:Cannot find type definition file for 'webworker'.

My TS version  is ES5. 

Thanks.

Link to comment
Share on other sites

1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.dom.d.ts(656,5): error TS2403: Build:Subsequent variable declarations must have the same type.  Variable 'source' must be of type 'any', but here has type 'Window'.
1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.dom.d.ts(2505,5): error TS2375: Build:Duplicate number index signature.
1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.dom.d.ts(3695,14): error TS2403: Build:Subsequent variable declarations must have the same type.  Variable 'srcElement' must be of type 'any', but here has type 'Element'.
1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.dom.d.ts(3766,5): error TS2375: Build:Duplicate number index signature.
1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.dom.d.ts(8044,14): error TS2403: Build:Subsequent variable declarations must have the same type.  Variable 'source' must be of type 'any', but here has type 'Window'.
1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.dom.d.ts(13333,14): error TS2403: Build:Subsequent variable declarations must have the same type.  Variable 'responseXML' must be of type 'any', but here has type 'Document'.
1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.dom.d.ts(14171,14): error TS2300: Build:Duplicate identifier 'EventListenerOrEventListenerObject'.
1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.dom.d.ts(14707,13): error TS2403: Build:Subsequent variable declarations must have the same type.  Variable 'location' must be of type 'WorkerLocation', but here has type 'Location'.
1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.dom.d.ts(14713,13): error TS2403: Build:Subsequent variable declarations must have the same type.  Variable 'navigator' must be of type 'WorkerNavigator', but here has type 'Navigator'.
1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.dom.d.ts(14740,13): error TS2403: Build:Subsequent variable declarations must have the same type.  Variable 'onerror' must be of type '(this: DedicatedWorkerGlobalScope, ev: ErrorEvent) => any', but here has type 'ErrorEventHandler'.
1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.dom.d.ts(14752,13): error TS2403: Build:Subsequent variable declarations must have the same type.  Variable 'onmessage' must be of type '(this: DedicatedWorkerGlobalScope, ev: MessageEvent) => any', but here has type '(this: Window, ev: MessageEvent) => any'.
1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.dom.d.ts(14823,13): error TS2403: Build:Subsequent variable declarations must have the same type.  Variable 'self' must be of type 'WorkerGlobalScope', but here has type 'Window'.
1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.dom.d.ts(14897,6): error TS2300: Build:Duplicate identifier 'AlgorithmIdentifier'.
1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.dom.d.ts(14898,6): error TS2300: Build:Duplicate identifier 'BodyInit'.
1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.dom.d.ts(14920,6): error TS2300: Build:Duplicate identifier 'IDBKeyPath'.
1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.dom.d.ts(14929,6): error TS2300: Build:Duplicate identifier 'RequestInfo'.
1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.dom.d.ts(14930,6): error TS2300: Build:Duplicate identifier 'USVString'.
1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.dom.d.ts(14934,6): error TS2300: Build:Duplicate identifier 'IDBValidKey'.
1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.dom.d.ts(14935,6): error TS2300: Build:Duplicate identifier 'BufferSource'.
1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.webworker.d.ts(1684,14): error TS2300: Build:Duplicate identifier 'EventListenerOrEventListenerObject'.
1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.webworker.d.ts(1743,6): error TS2300: Build:Duplicate identifier 'AlgorithmIdentifier'.
1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.webworker.d.ts(1744,6): error TS2300: Build:Duplicate identifier 'BodyInit'.
1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.webworker.d.ts(1745,6): error TS2300: Build:Duplicate identifier 'IDBKeyPath'.
1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.webworker.d.ts(1746,6): error TS2300: Build:Duplicate identifier 'RequestInfo'.
1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.webworker.d.ts(1747,6): error TS2300: Build:Duplicate identifier 'USVString'.

 

{
  "compileOnSave": true,
  "compilerOptions": {
    "experimentalDecorators": true,
    "module": "commonjs",
    "target": "es5",
    "sourceMap": true,
    "lib": [ "dom", "es2015.promise", "es5", "webworker" ]
  }
}

There are some errors after add "webworker" to "lib". 

Thanks.

Link to comment
Share on other sites

That seems rather odd. But still makes sense.

I wonder - what are you actually trying to do? compile Babylon? There is a dedicated Gulp Script for that, that compiles each module correctly.

The problem is that both modules should include a different lib, and then compile. Afterwards you are able to combine the two.

Link to comment
Share on other sites

:)

It obviously more than possible, as we are doing it at least once a day.

You should use gulp for that, and our predefined gulp script. You can read about it here - http://doc.babylonjs.com/generals/how_to_start .

We don't support compiling Babylon outside of gulp, mainly due to the problem you are currently facing. All modules, loaders, materials etc' are being built externally and then (if needed, like in the case of workers) integrated into a single file. 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...