node.jses6-modulesyarn-workspaces

Yarn workspace - use `"type": "module"` for entire workspace?


Can't find any exact info on this.

I have set "type": "module" in my workspace root package.json, and I kind of assumed it would work across all workspaces, but it doesn't, and i still have to add the type to all package.json's.

Is this possible? And if so, how do I get it working?

Added Note: I'm on my mobile, so no code access to copy, but, the specific error I'm getting is:

SyntaxError: Cannot use import statement outside a module


Solution

  • Each workspace is considered as an individual project and has it's own dependencies and configurations. Yarn, or any package manager that supports monorepos/workspaces as far as I know, does not support applying or extending the outer package JSON to the individual workspaces.

    This is by design as each individual workspace/project may have different dependencies and require different configurations.