NYPL-Simplified / webpub-viewer

8 stars 4 forks source link

Update to add .js extensions to imports #167

Closed M0nica closed 3 years ago

M0nica commented 3 years ago
hokei commented 3 years ago

I don't understand why this is necessary? Shouldn't ts files be reading other ts files?

M0nica commented 3 years ago

I don't understand why this is necessary? Shouldn't ts files be reading other ts files?

I was running into issues when trying to use the webpub-viewer's dist files in circulation-patron-web with the imports not being able to resolve. In webpub-viewer's static example we were solving resolving the imports that by passing the express server extensions: ["js"] so if an import was looking for ./Foo and ./Foo didn't exist it would also look for ./Foo.js and resolve to that if it it exists.

M0nica commented 3 years ago

I am going to close this as this was resolved by adding const withTM = require("next-transpile-modules")([ "library-simplified-webpub-viewer" ]); to the next-config in the consumer (circulation-patron-web).