d3 / d3-selection

Transform the DOM by selecting elements and joining to data.

Home Page:https://d3js.org/d3-selection

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Please provide your artifact as transpiled (CJS) code.

dwjohnston opened this issue · comments

With an out of the box create-react-app, this package won't work.

The reason is because your artifact's src/index.js uses ESM module syntax, which out of the box CRA's Jest won't attempt to transpile.

It will give a message like:

FAIL  src/App.test.js
  ● Test suite failed to run

    Jest encountered an unexpected token

    Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

    Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.

    By default "node_modules" folder is ignored by transformers.

I have a reproduction of this issue here:

https://github.com/dwjohnston/d3-untranspiled

The workaround, is to add the following to your CRA test script:

    "test": "react-scripts test --transformIgnorePatterns 'node_modules/!(d3-selection|another-dependency-here)'",

However, what would be nicer is if you can update your artifact compilation so the you provide both the CJS and ESM format files.

Sorry, but I’m not willing to do this.

Sorry, but I’m not willing to do this.

Even if I create the PR for you?

Even if I create the PR for you?

Correct.