Skip to content

Instantly share code, notes, and snippets.

@Security2431
Last active June 12, 2024 13:49
Show Gist options
  • Save Security2431/2b28f17e11870bb4b0e347673e16d5ba to your computer and use it in GitHub Desktop.
Save Security2431/2b28f17e11870bb4b0e347673e16d5ba to your computer and use it in GitHub Desktop.
shaka-player 4.3.4.patch
{
"scripts": {
"postinstall": "patch-package"
},
"devDependencies": {
"patch-package": "6.5.1",
"shaka-player": "4.3.4"
}
}
diff --git a/node_modules/shaka-player/dist/shaka-player.compiled.d.ts b/node_modules/shaka-player/dist/shaka-player.compiled.d.ts
index e8cb5c3..08e6c9a 100644
--- a/node_modules/shaka-player/dist/shaka-player.compiled.d.ts
+++ b/node_modules/shaka-player/dist/shaka-player.compiled.d.ts
@@ -4468,3 +4468,5 @@ declare namespace ಠ_ಠ.clutz {
static isTypeSupported (keySystem : string , contentType : string ) : boolean ;
}
}
+
+export default shaka;
\ No newline at end of file
diff --git a/node_modules/shaka-player/dist/shaka-player.ui.d.ts b/node_modules/shaka-player/dist/shaka-player.ui.d.ts
index 6dbd94e..0ad95ab 100644
--- a/node_modules/shaka-player/dist/shaka-player.ui.d.ts
+++ b/node_modules/shaka-player/dist/shaka-player.ui.d.ts
@@ -5054,3 +5054,5 @@ declare namespace shaka.extern {
declare namespace shaka.extern {
type UIVolumeBarColors = { base : string , level : string } ;
}
+
+export default shaka;
\ No newline at end of file
diff --git a/node_modules/shaka-player/index.d.ts b/node_modules/shaka-player/index.d.ts
new file mode 100644
index 0000000..86130b2
--- /dev/null
+++ b/node_modules/shaka-player/index.d.ts
@@ -0,0 +1,2 @@
+/// <reference path="./dist/shaka-player.compiled.d.ts" />
+/// <reference path="./dist/shaka-player.ui.d.ts" />
diff --git a/node_modules/shaka-player/ui.d.ts b/node_modules/shaka-player/ui.d.ts
new file mode 100644
index 0000000..7471371
--- /dev/null
+++ b/node_modules/shaka-player/ui.d.ts
@@ -0,0 +1,3 @@
+import shaka from 'shaka-player/dist/shaka-player.ui'
+export * from 'shaka-player/dist/shaka-player.ui'
+export default shaka;
@Security2431
Copy link
Author

Patched shaka-player 4.3.4 (TS export bug) 🐛

When you've installed shaka-player (reproduced in v4.3.4) into typescript project, you'll see the simmilar TS error:

error TS2306: File '/node_modules/shaka-player/dist/shaka-player.compiled.d.ts' is not a module

This happens because of missing exports in the shaka-player package.

Posible solutions 🛠

There are several things you can do to avoid this error:

  1. Delete all shaka-player types. It's cruel but effective 🤷‍♂️
 rm ./node_modules/shaka-player/dist/*.d.ts 
  1. Fork the shaka-player repo to your account and fix the bug manually. Sounds good, but that means, you should keep the repo up-to-date or hardcoded forever 💀
  2. Patch it by following my instructions below.

Patch Instructions 🧑‍🔧

  1. Run npm i -D patch-package.
  2. Download and move the shaka-player+4.3.4.patch file to /patches/shaka-player+4.3.4.patch in the root directory.
  3. Add "scripts": {"postinstall": "patch-package"} in package.json. This make patches to be applied each time people run npm install.
  4. Delete node_modules folder and execute npm install.

How to use ❓

Once you have reinstalled node_modules, you can import shaka-player into your typescript app.

import shaka from 'shaka-player';

I also exported types for shaka-player.ui.d.ts. So now you can easily import them:

import shaka from 'shaka-player/ui';

@Tenkir
Copy link

Tenkir commented Feb 21, 2023

Thanks for this. We use Yarn instead of NPM, here is a quick guide for yarn users:

In the root of your project:

  1. run yarn patch shaka-player
  2. Enter the contents of this gist into that newly created file, but remove the /node_modules/shaka-player from each file path

@mmichael0413
Copy link

Thank you for the gist @Security2431! I followed your instructions, but still running into TS errors during compilation:

[build:watch:lib:types:tsc] node_modules/shaka-player/dist/shaka-player.compiled.d.ts:503:62 - error TS2694: Namespace 'google.ima.dai.api' has no exported member 'StreamRequest'.
[build:watch:lib:types:tsc]
[build:watch:lib:types:tsc] 503     requestServerSideStream (imaRequest : google.ima.dai.api.StreamRequest , backupUrl ? : string ) : Promise < string > ;
[build:watch:lib:types:tsc]                                                                  ~~~~~~~~~~~~~
[build:watch:lib:types:tsc]
[build:watch:lib:types:tsc] node_modules/shaka-player/dist/shaka-player.compiled.d.ts:636:37 - error TS2694: Namespace 'google.ima' has no exported member 'Ad'.
[build:watch:lib:types:tsc]
[build:watch:lib:types:tsc] 636     constructor (imaAd : google.ima.Ad , imaAdManager : google.ima.AdsManager , video : HTMLMediaElement | null ) ;
[build:watch:lib:types:tsc]                                         ~~
[build:watch:lib:types:tsc]
[build:watch:lib:types:tsc] node_modules/shaka-player/dist/shaka-player.compiled.d.ts:664:45 - error TS2694: Namespace 'google.ima.dai.api' has no exported member 'Ad'.
[build:watch:lib:types:tsc]
[build:watch:lib:types:tsc] 664     constructor (imaAd : google.ima.dai.api.Ad | null , video : HTMLMediaElement | null ) ;
[build:watch:lib:types:tsc]                                                 ~~
[build:watch:lib:types:tsc]
[build:watch:lib:types:tsc] node_modules/shaka-player/dist/shaka-player.compiled.d.ts:1537:9 - error TS2506: 'AbortController' is referenced directly or indirectly in its own base expression.
[build:watch:lib:types:tsc]
[build:watch:lib:types:tsc] 1537   class AbortController extends AbortController {
[build:watch:lib:types:tsc]              ~~~~~~~~~~~~~~~
[build:watch:lib:types:tsc]
[build:watch:lib:types:tsc] node_modules/shaka-player/dist/shaka-player.compiled.d.ts:3092:41 - error TS2694: Namespace 'google.ima' has no exported member 'AdDisplayContainer'.
[build:watch:lib:types:tsc]
[build:watch:lib:types:tsc] 3092     constructor (container : google.ima.AdDisplayContainer ) ;
[build:watch:lib:types:tsc]                                              ~~~~~~~~~~~~~~~~~~
[build:watch:lib:types:tsc]
[build:watch:lib:types:tsc] node_modules/shaka-player/dist/shaka-player.compiled.d.ts:3097:34 - error TS2694: Namespace 'google.ima' has no exported member 'ImaSdkSettings'.
[build:watch:lib:types:tsc]
[build:watch:lib:types:tsc] 3097     getSettings ( ) : google.ima.ImaSdkSettings | null ;
[build:watch:lib:types:tsc]                                       ~~~~~~~~~~~~~~
[build:watch:lib:types:tsc]
[build:watch:lib:types:tsc] node_modules/shaka-player/dist/shaka-player.compiled.d.ts:3176:130 - error TS2694: Namespace 'google.ima.dai.api' has no exported member 'UiSettings'.
[build:watch:lib:types:tsc]
[build:watch:lib:types:tsc] 3176     constructor (videoElement : HTMLMediaElement | null , adUiElement ? : HTMLElement | null , uiSettings ? : google.ima.dai.api.UiSettings | null ) ;
[build:watch:lib:types:tsc]                                                                                                                                       ~~~~~~~~~~
[build:watch:lib:types:tsc]
[build:watch:lib:types:tsc] node_modules/shaka-player/dist/shaka-player.compiled.d.ts:3185:55 - error TS2694: Namespace 'google.ima.dai.api' has no exported member 'StreamRequest'.
[build:watch:lib:types:tsc]
[build:watch:lib:types:tsc] 3185     requestStream (streamRequest : google.ima.dai.api.StreamRequest | null ) : any ;
[build:watch:lib:types:tsc]                                                            ~~~~~~~~~~~~~
[build:watch:lib:types:tsc]
[build:watch:lib:types:tsc] node_modules/shaka-player/dist/shaka-player.compiled.d.ts:3193:29 - error TS2694: Namespace 'google.ima' has no exported member 'ImaSdkSettings'.
[build:watch:lib:types:tsc]
[build:watch:lib:types:tsc] 3193   let settings : google.ima.ImaSdkSettings ;
[build:watch:lib:types:tsc]                                  ~~~~~~~~~~~~~~
[build:watch:lib:types:tsc]
[build:watch:lib:types:tsc] node_modules/shaka-player/dist/shaka-player.compiled.d.ts:3596:62 - error TS2694: Namespace 'google.ima.dai.api' has no exported member 'StreamRequest'.
[build:watch:lib:types:tsc]
[build:watch:lib:types:tsc] 3596     requestServerSideStream (imaRequest : google.ima.dai.api.StreamRequest , backupUrl ? : string ) : Promise < string > ;

I also can't import the types as you suggested: import shaka from 'shaka-player/ui';:

Cannot find module 'shaka-player/ui' from '../src/lib/audio/index.tsx'

And if I try to declare the external module shaka-player/ui to avoid the above error, I lose all the types.

Any suggestions?

@Security2431
Copy link
Author

Security2431 commented Mar 22, 2023

@mmichael0413 Hi Michael, thanks for your feedback. I've uploaded some changes to the shaka-player+4.3.4.patch file. Could you please apply them to your project and get back to me?

If that doesn't help, I'd really appreciate it if you could provide the bare minimum codebase so I can reproduce the bug.

As a temporary solution, I'd recommend importing the UI directly as import shaka from 'shaka-player/dist/shaka-player.ui'

@TDUser91
Copy link

Hi @Security2431 , I've followed to instructions on how to patch shaka-player for the TS export bug, I no longer get the error at import that says it's not not a module, however when I run the app I get this :


WARNING in ./node_modules/shaka-player/dist/shaka-player.ui.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/array/entries.js' file: Error: ENOENT: no such file or directory, open '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/array/entries.js'

WARNING in ./node_modules/shaka-player/dist/shaka-player.ui.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/array/find.js' file: Error: ENOENT: no such file or directory, open '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/array/find.js'

WARNING in ./node_modules/shaka-player/dist/shaka-player.ui.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/array/findindex.js' file: Error: ENOENT: no such file or directory, open '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/array/findindex.js'

WARNING in ./node_modules/shaka-player/dist/shaka-player.ui.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/array/from.js' file: Error: ENOENT: no such file or directory, open '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/array/from.js'

WARNING in ./node_modules/shaka-player/dist/shaka-player.ui.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/array/includes.js' file: Error: ENOENT: no such file or directory, open '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/array/includes.js'

WARNING in ./node_modules/shaka-player/dist/shaka-player.ui.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/array/keys.js' file: Error: ENOENT: no such file or directory, open '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/array/keys.js'

WARNING in ./node_modules/shaka-player/dist/shaka-player.ui.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/array/values.js' file: Error: ENOENT: no such file or directory, open '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/array/values.js'

WARNING in ./node_modules/shaka-player/dist/shaka-player.ui.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/execute_async_generator.js' file: Error: ENOENT: no such file or directory, open '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/execute_async_generator.js'

WARNING in ./node_modules/shaka-player/dist/shaka-player.ui.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/generator_engine.js' file: Error: ENOENT: no such file or directory, open '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/generator_engine.js'

WARNING in ./node_modules/shaka-player/dist/shaka-player.ui.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/map.js' file: Error: ENOENT: no such file or directory, open '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/map.js'

WARNING in ./node_modules/shaka-player/dist/shaka-player.ui.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/math/log2.js' file: Error: ENOENT: no such file or directory, open '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/math/log2.js'

WARNING in ./node_modules/shaka-player/dist/shaka-player.ui.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/math/trunc.js' file: Error: ENOENT: no such file or directory, open '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/math/trunc.js'

WARNING in ./node_modules/shaka-player/dist/shaka-player.ui.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/number/isnan.js' file: Error: ENOENT: no such file or directory, open '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/number/isnan.js'

WARNING in ./node_modules/shaka-player/dist/shaka-player.ui.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/object/assign.js' file: Error: ENOENT: no such file or directory, open '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/object/assign.js'

WARNING in ./node_modules/shaka-player/dist/shaka-player.ui.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/object/entries.js' file: Error: ENOENT: no such file or directory, open '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/object/entries.js'

WARNING in ./node_modules/shaka-player/dist/shaka-player.ui.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/object/is.js' file: Error: ENOENT: no such file or directory, open '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/object/is.js'

WARNING in ./node_modules/shaka-player/dist/shaka-player.ui.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/object/values.js' file: Error: ENOENT: no such file or directory, open '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/object/values.js'

WARNING in ./node_modules/shaka-player/dist/shaka-player.ui.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/promise/finally.js' file: Error: ENOENT: no such file or directory, open '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/promise/finally.js'

WARNING in ./node_modules/shaka-player/dist/shaka-player.ui.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/promise/promise.js' file: Error: ENOENT: no such file or directory, open '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/promise/promise.js'

WARNING in ./node_modules/shaka-player/dist/shaka-player.ui.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/set.js' file: Error: ENOENT: no such file or directory, open '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/set.js'

WARNING in ./node_modules/shaka-player/dist/shaka-player.ui.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/string/includes.js' file: Error: ENOENT: no such file or directory, open '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/string/includes.js'

WARNING in ./node_modules/shaka-player/dist/shaka-player.ui.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/string/repeat.js' file: Error: ENOENT: no such file or directory, open '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/string/repeat.js'

WARNING in ./node_modules/shaka-player/dist/shaka-player.ui.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/string/startswith.js' file: Error: ENOENT: no such file or directory, open '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/string/startswith.js'

WARNING in ./node_modules/shaka-player/dist/shaka-player.ui.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/symbol.js' file: Error: ENOENT: no such file or directory, open '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/symbol.js'

WARNING in ./node_modules/shaka-player/dist/shaka-player.ui.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/util/arrayfromiterable.js' file: Error: ENOENT: no such file or directory, open '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/util/arrayfromiterable.js'

WARNING in ./node_modules/shaka-player/dist/shaka-player.ui.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/util/arrayfromiterator.js' file: Error: ENOENT: no such file or directory, open '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/util/arrayfromiterator.js'

WARNING in ./node_modules/shaka-player/dist/shaka-player.ui.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/util/arrayiterator.js' file: Error: ENOENT: no such file or directory, open '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/util/arrayiterator.js'

WARNING in ./node_modules/shaka-player/dist/shaka-player.ui.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/util/assign.js' file: Error: ENOENT: no such file or directory, open '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/util/assign.js'

WARNING in ./node_modules/shaka-player/dist/shaka-player.ui.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/util/inherits.js' file: Error: ENOENT: no such file or directory, open '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/util/inherits.js'

WARNING in ./node_modules/shaka-player/dist/shaka-player.ui.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/util/iteratorfromarray.js' file: Error: ENOENT: no such file or directory, open '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/util/iteratorfromarray.js'

WARNING in ./node_modules/shaka-player/dist/shaka-player.ui.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/util/makeiterator.js' file: Error: ENOENT: no such file or directory, open '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/util/makeiterator.js'

WARNING in ./node_modules/shaka-player/dist/shaka-player.ui.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/util/restarguments.js' file: Error: ENOENT: no such file or directory, open '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/util/restarguments.js'

WARNING in ./node_modules/shaka-player/dist/shaka-player.ui.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/util/setprototypeof.js' file: Error: ENOENT: no such file or directory, open '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/util/setprototypeof.js'

WARNING in ./node_modules/shaka-player/dist/shaka-player.ui.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/weakmap.js' file: Error: ENOENT: no such file or directory, open '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/es6/weakmap.js'

WARNING in ./node_modules/shaka-player/dist/shaka-player.ui.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/util/checkstringargs.js' file: Error: ENOENT: no such file or directory, open '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/util/checkstringargs.js'

WARNING in ./node_modules/shaka-player/dist/shaka-player.ui.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/util/defineproperty.js' file: Error: ENOENT: no such file or directory, open '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/util/defineproperty.js'

WARNING in ./node_modules/shaka-player/dist/shaka-player.ui.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/util/findinternal.js' file: Error: ENOENT: no such file or directory, open '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/util/findinternal.js'

WARNING in ./node_modules/shaka-player/dist/shaka-player.ui.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/util/global.js' file: Error: ENOENT: no such file or directory, open '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/util/global.js'

WARNING in ./node_modules/shaka-player/dist/shaka-player.ui.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/util/objectcreate.js' file: Error: ENOENT: no such file or directory, open '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/util/objectcreate.js'

WARNING in ./node_modules/shaka-player/dist/shaka-player.ui.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/util/owns.js' file: Error: ENOENT: no such file or directory, open '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/util/owns.js'

WARNING in ./node_modules/shaka-player/dist/shaka-player.ui.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/util/polyfill.js' file: Error: ENOENT: no such file or directory, open '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/dist/src/com/google/javascript/jscomp/js/util/polyfill.js'

WARNING in ./node_modules/shaka-player/dist/shaka-player.ui.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/node_modules/eme-encryption-scheme-polyfill/index.js' file: Error: ENOENT: no such file or directory, open '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/node_modules/eme-encryption-scheme-polyfill/index.js'

WARNING in ./node_modules/shaka-player/dist/shaka-player.ui.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/node_modules/google-closure-library/closure/goog/base.js' file: Error: ENOENT: no such file or directory, open '/home/lehbabm1/Bureau/test_reactjs_drm_video/react_shaka_ts/node_modules/shaka-player/node_modules/google-closure-library/closure/goog/base.js'

What I'm I doing wrong ? did I miss something ?

@Security2431
Copy link
Author

@TDUser91 I have to investigate the issue. Can you share the codebase, it'll help me a lot? 🙏

@TDUser91
Copy link

I added a sample repo you can find it here: https://github.com/TDUser91/react_test_drm. Thanks

@Security2431
Copy link
Author

@TDUser91 What I've found out so far, this is the issue in shaka-player library. I've tested on the bare shaka-player library and even upgraded to the shaka-player@4.3.7 version. I have no other solution, try playing around with the tsconfig settings to avoid these warnings

@TDUser91
Copy link

TDUser91 commented Jul 21, 2023

EDIT: added more to the reply

Thank you for taking the time and the replies.

Here's what I've found from my end, I believe the issue is coming from web-pack (or at least that's what I've understood from this issue and this discussion). If you can take a look and confirm that ?

I've added this GENERATE_SOURCEMAP=false in my .env file and the warnings seems to be gone. I even ran the app in prod with npm run build

My concern now is: does disabling those mapping warnings; will disable all the warnings coming on my project, just those of the node_module or only those of shaka-player ?

What do you think ?

I must add thought, I ran into this issue only with this machine (Linux), when I tried the same code on (Windows, Mac) I didn't have the warnings/errors. But I fail to see how the OS if at all has something to do with this ? (all OSs were running same node, npm and shaka player versions).

@Security2431
Copy link
Author

Way to go. This is the possible solution webpack ignoring warnings. It will turn off all the node_modules warnings.
FYI: node_modules is a self-contained library that we shouldn't tamper with. So, I think it's a good solution 👍

P.S. I've dug into the shaka-player library and found a lot of errors under the hood 🤫

@loicraux
Copy link

loicraux commented Sep 11, 2023

Thank you for the gist @Security2431! I followed your instructions, but still running into TS errors during compilation:

[build:watch:lib:types:tsc] node_modules/shaka-player/dist/shaka-player.compiled.d.ts:503:62 - error TS2694: Namespace 'google.ima.dai.api' has no exported member 'StreamRequest'.
[build:watch:lib:types:tsc]
[build:watch:lib:types:tsc] 503     requestServerSideStream (imaRequest : google.ima.dai.api.StreamRequest , backupUrl ? : string ) : Promise < string > ;
[build:watch:lib:types:tsc]                                                                  ~~~~~~~~~~~~~
[build:watch:lib:types:tsc]
[build:watch:lib:types:tsc] node_modules/shaka-player/dist/shaka-player.compiled.d.ts:636:37 - error TS2694: Namespace 'google.ima' has no exported member 'Ad'.
[build:watch:lib:types:tsc]
[build:watch:lib:types:tsc] 636     constructor (imaAd : google.ima.Ad , imaAdManager : google.ima.AdsManager , video : HTMLMediaElement | null ) ;
[build:watch:lib:types:tsc]                                         ~~
[build:watch:lib:types:tsc]
[build:watch:lib:types:tsc] node_modules/shaka-player/dist/shaka-player.compiled.d.ts:664:45 - error TS2694: Namespace 'google.ima.dai.api' has no exported member 'Ad'.
[build:watch:lib:types:tsc]
[build:watch:lib:types:tsc] 664     constructor (imaAd : google.ima.dai.api.Ad | null , video : HTMLMediaElement | null ) ;
[build:watch:lib:types:tsc]                                                 ~~
[build:watch:lib:types:tsc]
[build:watch:lib:types:tsc] node_modules/shaka-player/dist/shaka-player.compiled.d.ts:1537:9 - error TS2506: 'AbortController' is referenced directly or indirectly in its own base expression.
[build:watch:lib:types:tsc]
[build:watch:lib:types:tsc] 1537   class AbortController extends AbortController {
[build:watch:lib:types:tsc]              ~~~~~~~~~~~~~~~
[build:watch:lib:types:tsc]
[build:watch:lib:types:tsc] node_modules/shaka-player/dist/shaka-player.compiled.d.ts:3092:41 - error TS2694: Namespace 'google.ima' has no exported member 'AdDisplayContainer'.
[build:watch:lib:types:tsc]
[build:watch:lib:types:tsc] 3092     constructor (container : google.ima.AdDisplayContainer ) ;
[build:watch:lib:types:tsc]                                              ~~~~~~~~~~~~~~~~~~
[build:watch:lib:types:tsc]
[build:watch:lib:types:tsc] node_modules/shaka-player/dist/shaka-player.compiled.d.ts:3097:34 - error TS2694: Namespace 'google.ima' has no exported member 'ImaSdkSettings'.
[build:watch:lib:types:tsc]
[build:watch:lib:types:tsc] 3097     getSettings ( ) : google.ima.ImaSdkSettings | null ;
[build:watch:lib:types:tsc]                                       ~~~~~~~~~~~~~~
[build:watch:lib:types:tsc]
[build:watch:lib:types:tsc] node_modules/shaka-player/dist/shaka-player.compiled.d.ts:3176:130 - error TS2694: Namespace 'google.ima.dai.api' has no exported member 'UiSettings'.
[build:watch:lib:types:tsc]
[build:watch:lib:types:tsc] 3176     constructor (videoElement : HTMLMediaElement | null , adUiElement ? : HTMLElement | null , uiSettings ? : google.ima.dai.api.UiSettings | null ) ;
[build:watch:lib:types:tsc]                                                                                                                                       ~~~~~~~~~~
[build:watch:lib:types:tsc]
[build:watch:lib:types:tsc] node_modules/shaka-player/dist/shaka-player.compiled.d.ts:3185:55 - error TS2694: Namespace 'google.ima.dai.api' has no exported member 'StreamRequest'.
[build:watch:lib:types:tsc]
[build:watch:lib:types:tsc] 3185     requestStream (streamRequest : google.ima.dai.api.StreamRequest | null ) : any ;
[build:watch:lib:types:tsc]                                                            ~~~~~~~~~~~~~
[build:watch:lib:types:tsc]
[build:watch:lib:types:tsc] node_modules/shaka-player/dist/shaka-player.compiled.d.ts:3193:29 - error TS2694: Namespace 'google.ima' has no exported member 'ImaSdkSettings'.
[build:watch:lib:types:tsc]
[build:watch:lib:types:tsc] 3193   let settings : google.ima.ImaSdkSettings ;
[build:watch:lib:types:tsc]                                  ~~~~~~~~~~~~~~
[build:watch:lib:types:tsc]
[build:watch:lib:types:tsc] node_modules/shaka-player/dist/shaka-player.compiled.d.ts:3596:62 - error TS2694: Namespace 'google.ima.dai.api' has no exported member 'StreamRequest'.
[build:watch:lib:types:tsc]
[build:watch:lib:types:tsc] 3596     requestServerSideStream (imaRequest : google.ima.dai.api.StreamRequest , backupUrl ? : string ) : Promise < string > ;

Any suggestions?

You should set skipLibCheck option to true in your tsconfig.json file.

@enjikaka
Copy link

enjikaka commented May 6, 2024

shaka-player@4.8.1.patch

diff --git a/dist/shaka-player.compiled.d.ts b/dist/shaka-player.compiled.d.ts
index e6dcbc69da69831c5b327d4ca4a28c4a648caf8a..19c4e9b9d816f5cf12a4e2b8b3d3cf2e326c4e57 100644
--- a/dist/shaka-player.compiled.d.ts
+++ b/dist/shaka-player.compiled.d.ts
@@ -5424,6 +5424,7 @@ declare namespace ಠ_ಠ.clutz {
     static isTypeSupported (keySystem : string , contentType : string ) : boolean ;
   }
 }
+export default shaka;
 // Generated from /home/runner/work/shaka-player/shaka-player/externs/webos.js
 declare namespace PalmSystem {
   let deviceInfo : string ;
diff --git a/dist/shaka-player.ui.d.ts b/dist/shaka-player.ui.d.ts
index 5b3b8753930568a83a6d1d8d6d18357de4d8424a..4301fa807b03741f3384137432cb206df390287b 100644
--- a/dist/shaka-player.ui.d.ts
+++ b/dist/shaka-player.ui.d.ts
@@ -6128,3 +6128,4 @@ declare namespace shaka.extern {
 declare namespace shaka.extern {
   type UIVolumeBarColors = { base : string , level : string } ;
 }
+export default shaka;
\ No newline at end of file
diff --git a/index.d.ts b/index.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..86130b219f20157404545f817f41485ab13ced25
--- /dev/null
+++ b/index.d.ts
@@ -0,0 +1,2 @@
+/// <reference path="./dist/shaka-player.compiled.d.ts" />
+/// <reference path="./dist/shaka-player.ui.d.ts" />
diff --git a/ui.d.ts b/ui.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..5118563d30558c6692fd35b4f4bd04b6e8874288
--- /dev/null
+++ b/ui.d.ts
@@ -0,0 +1,3 @@
+import shaka from './dist/shaka-player.ui'
+export * from './dist/shaka-player.ui'
+export default shaka;

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