jamsinclair / jSquash

Browser & Web Worker focussed wasm bundles derived from the Squoosh App.
Apache License 2.0
222 stars 14 forks source link

Module not found #47

Closed zehawki closed 6 months ago

zehawki commented 7 months ago

Describe the bug

Getting a Module not found: Can't resolve 'https://unpkg.com/@jsquash/jpeg?module'

To Reproduce

Just the very basic - added an import statement as given here https://github.com/jamsinclair/jSquash?tab=readme-ov-file#usage-in-the-browser

Environment

React 17 + CRA 4 + Craco with config:

module.exports = {
  webpack: {
    configure: {
      module: {
        rules: [
          {
            type: 'javascript/auto',
            test: /\.mjs$/,
            include: /node_modules/,
          },
        ],
      },
    },
  },
}

Happy to provide any further info. I find this part about the JS toolchaining quite confusing, and my knowledge in this area is poor.

jamsinclair commented 6 months ago

@zehawki I am not overly familiar with create react app. I suspect this happens during the webpack build. Webpack will need the module installed locally as it cannot resolve URL imports.

Installing with npm install -S @jsquash/jpeg and importing it as shown in the docs should solve the issue 👍