blueprint core v2.0 has an invalid es6 module build

Created on 16 Feb 2018  路  2Comments  路  Source: palantir/blueprint

Bug report

  • __Package version(s)__: blueprint core v2.0.0-rc.1:
  • __Browser and OS versions__: all

Steps to reproduce

Blueprint exposes an invalid "module" field in package.json due to incorrect behaviour of TypeScript for CommonJS module imports

  1. Bundle blueprint with parceljs.
  2. Since it exploses a "module" field, ~blueprint~ parceljs will use babel to compile it.
  3. Since Blueprint is built with typescript, incorrect ES6 code is generated that causes the following error:
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.

Actual behavior

Throws above error.

Expected behavior

Module works correctly

tooling

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.

All 2 comments

Until this is fixed can you please remove the module fields from package.json ? They are completely preventing us from using blueprint with parcel.

Was this page helpful?
0 / 5 - 0 ratings