#Importing JS Files of a Library in React Typescript Project

13 messages · Page 1 of 1 (latest)

hoary rose
#

Hello! I have a local copy of a JS Repo. I want to import the uncompiled version of that JS Repo. In case of Vanilla JS to use this library I just need to import these JS Files as shown in Image 2. How do I achieve the same in a React Typescript project? That JS library also exposes typings in externs folder.

hoary rose
#

!helper

calm badger
#

@hoary rose cant you just npm link

hoary rose
#

I was able to do that by creating an index.js file in my JS base library and exporting the required dependencies however I am getting this error

Uncaught SyntaxError: The requested module '/@fs/D:/Github/Private/limetree/packages/shaka-player/dist/shaka-player.compiled.js' does not provide an export named 'default' (at layout.tsx:5:8)

#

This is how I am importing it

calm badger
#

did you change export signature

hoary rose
#

Yes it is, But actually there was no such file exported from index.js earlier I was just restricted to use compiled version now to make use of uncompiled version I created this index.js file where I have exported the files I require

#

So earlier I just did import shaka from 'shaka-player/dist/shaka-player.compiled.js'
This doesn't allow me to modify the source code of shaka-player

#

For the same reason, to use uncompiled version which is purely JS based, I created this default export

calm badger
#

are you sure you are building it correctly

hoary rose
#

Sorry, just to clarify to in case of uncompiled version I dont need to build. Those are just vanilla JS files which possibly as IIFE and I want to import those

calm badger