Module interop compatibility issue on Node 12.19
tylerbrostrom opened this issue · 2 comments
tylerbrostrom commented
When running the microsite
CLI on Node 12.19.1, the following error is thrown:
(node:53186) ExperimentalWarning: The ESM module loader is experimental.
(node:53186) UnhandledPromiseRejectionWarning: file:///Users/tyler/dev/_temp/microsite-test/node_modules/microsite/dist/utils/command.js:6
import { createConfiguration } from "snowpack";
^^^^^^^^^^^^^^^^^^^
SyntaxError: The requested module 'snowpack' is expected to be of type CommonJS, which does not support named exports. CommonJS modules can be imported by importing the default export.
For example:
import pkg from 'snowpack';
const { createConfiguration } = pkg;
at ModuleJob._instantiate (internal/modules/esm/module_job.js:97:21)
at async ModuleJob.run (internal/modules/esm/module_job.js:143:20)
at async Loader.import (internal/modules/esm/loader.js:182:24)
(node:53186) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:53186) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Steps to reproduce:
npm init microsite some-dir
cd some-dir
npm i
npm start
Known workarounds
- Upgrade Node 12 to latest (12.20.1 at the time of writing)
- Upgrade Node to LTS (14.15.4 at the time of writing)
Other details
This error occurs for microsite 1.0.3 as well as 1.1.0-next.2.
natemoo-re commented
So I did a bit of digging here. It looks like node@12.20.x
shipped a fairly big interop improvement to support named exports for most CJS packages. Snowpack falls into this category of a now-supported package.
I think the best solution here would be to bump Microsite's minimum recommended Node version from exactly 12.19.0
to Latest v12.x
to keep in sync with Node's LTS. Does that sound reasonable?
tylerbrostrom commented
Agreed! e51a604 documents that change perfectly 👌