Blueprint exposes an invalid "module" field in package.json due to incorrect behaviour of TypeScript for CommonJS module imports
Uncaught TypeError: classNames is not a function
at Spinner.render (spinner.js:24)
Looking at the spinner component, the ES6 generated code looks like this:
import * as tslib_1 from "tslib";
import * as classNames from "classnames";
import * as React from "react";
// ... snip ...
var classes = classNames(Classes.SPINNER, Classes.intentClass(intent), {
// ... rest of code ...
Even though TypeScript allows it, importing ES5 modules as ES6 module namespaces is not allowed, and when targeting ES6 modules typescript will generate invalid code.
The solution is to import classNames using its default export:
import classNames from 'classnames'
or alternativey not have a "module" field in package.json so that parcel uses the main field.
Throws above error.
Module works correctly
sounds like a job for --esModuleInterop! https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-7.html
Until this is fixed can you please remove the module fields from package.json ? They are completely preventing us from using blueprint with parcel.
Most helpful comment
Until this is fixed can you please remove the module fields from
package.json? They are completely preventing us from using blueprint with parcel.