Closed fwouts closed 3 years ago
Unfortunately this is a casualty of CommonJS <-> ESM interop. From the TypeScript docs:
the ES6 modules spec states that a namespace import
(import * as x)
can only be an object, by having TypeScript treating it the same as =require("x")
then TypeScript allowed for the import to be treated as a function and be callable. This breaks the spec’s recommendations.
So the .default
is expected, is somewhat of a loose standard, and actually does solve a lot of problems. But it’s just something to expect whenever you try and import CommonJS code into ESM.
Bug Report Quick Checklist
Describe the bug
An import statement such as
import Head from "next/head"
assignsHead
the value{__esModule: true, defaultHead: function, default: function}
instead of the expected function.To Reproduce
yarn snowpack dev
Expected behavior
The expected behaviour can be experienced by running
yarn dev
, which runs this Next.js app with Webpack instead.Anything else?
I investigated this, and found that it's caused by
node_modules/next/head.js
having the following code:The bug fixes itself if I replace it with:
I wonder if this could be an issue with Rollup?