framework icon indicating copy to clipboard operation
framework copied to clipboard

[FEAT] Add ES Modules support

Open kevinfaveri opened this issue 4 years ago • 2 comments

  • Maizzle Version: 3.0.0
  • Node.js Version: 14

Using maizzle version 3.0.0 with its Cli it does not load the config file if the project has "type": "module" specified in the package.json: Instead rename config.maizzle.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from

I got this log monkey patching the code.... But the library just returns: UnhandledPromiseRejectionWarning: Error: could not load 'config.maizzle.js'

image

kevinfaveri avatar May 24 '21 21:05 kevinfaveri

For anyone reading this: a workaround, not proper ES Modules support, is using a JSON file as the config file, which will not trigger NodeJS ES Modules restrictions: config.local.js -> config.local.json

This will work because commonjs (which maizzle uses) syntax support will try to implicit import JS or JSON files... And if you use a JSON file, Node JS es modules import rules will not apply...

kevinfaveri avatar May 24 '21 22:05 kevinfaveri

@kevinfaveri thanks!

Lipemenezes avatar May 24 '21 22:05 Lipemenezes

Converting this into a discussion for now, as it'll be a while until we can add proper ES modules support, given the state of the ecosystem and the dependencies in Maizzle. Thanks!

cossssmin avatar Oct 01 '22 13:10 cossssmin