The apps/legit/service/Legit.mjs service uses dynamic imports for external modules (from esm.sh) to keep the initial bundle size low.
const {openLegitFs} = await import('https://esm.sh/@legit-sdk/core');
const fsModule = await import('https://esm.sh/memfs');
Webpack attempts to resolve these URLs as local modules or npm packages during the build process, causing the npm run build-all command to fail with:
Error: The target environment doesn't support dynamic import() syntax so it's not possible to use external type 'module' within a script
Goal:
Prevent Webpack from attempting to process these specific import statements so they are handled natively by the browser at runtime.
Task:
Modify apps/legit/service/Legit.mjs to add /* webpackIgnore: true */ comments to the dynamic imports.
const {openLegitFs} = await import( 'https://esm.sh/@legit-sdk/core');
const fsModule = await import( 'https://esm.sh/memfs');
This should resolve the build errors while maintaining the dynamic loading functionality in the browser.
The
apps/legit/service/Legit.mjsservice uses dynamic imports for external modules (fromesm.sh) to keep the initial bundle size low.const {openLegitFs} = await import('https://esm.sh/@legit-sdk/core'); const fsModule = await import('https://esm.sh/memfs');Webpack attempts to resolve these URLs as local modules or npm packages during the build process, causing the
npm run build-allcommand to fail with:Error: The target environment doesn't support dynamic import() syntax so it's not possible to use external type 'module' within a scriptGoal: Prevent Webpack from attempting to process these specific import statements so they are handled natively by the browser at runtime.
Task: Modify
apps/legit/service/Legit.mjsto add/* webpackIgnore: true */comments to the dynamic imports.const {openLegitFs} = await import(/* webpackIgnore: true */ 'https://esm.sh/@legit-sdk/core'); const fsModule = await import(/* webpackIgnore: true */ 'https://esm.sh/memfs');This should resolve the build errors while maintaining the dynamic loading functionality in the browser.