0

I've got a nextjs 13 project and I need certain files (web audio api worklets from let's say ./src/worklets/*.ts) to be compiled and bundled separately.

None of the solutions I found online worked for me.

This is as far as I've gotten

// next.config.js

/** @type {import('next').NextConfig} */
const nextConfig = {
  webpack: (config) => {
    return Object.assign({}, config, {
      entry: async () => {
        const entryConfig = await config.entry();

        const newEntryConfig = {
          ...entryConfig,
          // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
          // I ASSUME I NEED TO ADD SOMETHING HERE
          // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
        };

        return newEntryConfig;
      }
    });

    return config;
  }
}

module.exports = nextConfig
v0rs4
  • 106
  • 5
  • Are these files supposed to be compiled into individual .js files and publicly available as if they were placed in the `public` folder? – Igor Danchenko Jun 27 '23 at 22:40
  • Yup, I think that's exactly what I need. So I can use`addModule` | See: https://developer.mozilla.org/en-US/docs/Web/API/Worklet/addModule – v0rs4 Jun 27 '23 at 22:55
  • There were 2 feature requests to support this natively in Next.js, but those tickets got nowhere - https://github.com/vercel/next.js/issues/29472, https://github.com/vercel/next.js/issues/24907 | Please also see the following thread - https://stackoverflow.com/a/71387919/21872981 – Igor Danchenko Jun 27 '23 at 23:10
  • It'll take me some time to go thru the stuff you sent me. I'll keep you posted. Thx. – v0rs4 Jun 27 '23 at 23:40
  • @IgorDanchenko, I wonder if there's more recent stuff regarding worklets, all of that above is like 2 years old. – v0rs4 Jun 28 '23 at 03:22

0 Answers0