NIVO / ScatterPlot дает ошибку во время установки - PullRequest
1 голос
/ 03 мая 2020

Я пытаюсь установить nivo и создать Scatterplot, используя пример по умолчанию (https://nivo.rocks/scatterplot/).

Когда я делаю npm установку для core, axes, legends, scales моего веб-пакета строит нормально. Затем, когда я пытаюсь установить @nivo/scatterplot@0.61 и выполнить сборку, я получаю следующую ошибку:

ERROR in ./~/d3-delaunay/dist/d3-delaunay.js
Module parse failed: /Users/phil/GoogleDrive/go/src/app/frontend/node_modules/d3-delaunay/dist/d3-delaunay.js Unexpected token (933:53)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (933:53)
    at Parser.pp$4.raise (/Users/phil/GoogleDrive/go/src/app/frontend/node_modules/acorn/dist/acorn.js:2221:15)
    at Parser.pp.unexpected (/Users/phil/GoogleDrive/go/src/app/frontend/node_modules/acorn/dist/acorn.js:603:10)
    at Parser.pp$3.parseExprAtom (/Users/phil/GoogleDrive/go/src/app/frontend/node_modules/acorn/dist/acorn.js:1822:12)
    at Parser.pp$3.parseExprSubscripts (/Users/phil/GoogleDrive/go/src/app/frontend/node_modules/acorn/dist/acorn.js:1715:21)
    at Parser.pp$3.parseMaybeUnary (/Users/phil/GoogleDrive/go/src/app/frontend/node_modules/acorn/dist/acorn.js:1692:19)
    at Parser.pp$3.parseExprOp (/Users/phil/GoogleDrive/go/src/app/frontend/node_modules/acorn/dist/acorn.js:1656:43)
    at Parser.pp$3.parseExprOps (/Users/phil/GoogleDrive/go/src/app/frontend/node_modules/acorn/dist/acorn.js:1639:17)
    at Parser.pp$3.parseMaybeConditional (/Users/phil/GoogleDrive/go/src/app/frontend/node_modules/acorn/dist/acorn.js:1620:21)
    at Parser.pp$3.parseMaybeAssign (/Users/phil/GoogleDrive/go/src/app/frontend/node_modules/acorn/dist/acorn.js:1597:21)
    at Parser.pp$3.parseExprList (/Users/phil/GoogleDrive/go/src/app/frontend/node_modules/acorn/dist/acorn.js:2165:22)
    at Parser.pp$3.parseSubscripts (/Users/phil/GoogleDrive/go/src/app/frontend/node_modules/acorn/dist/acorn.js:1741:35)
    at Parser.pp$3.parseExprSubscripts (/Users/phil/GoogleDrive/go/src/app/frontend/node_modules/acorn/dist/acorn.js:1718:17)
    at Parser.pp$3.parseMaybeUnary (/Users/phil/GoogleDrive/go/src/app/frontend/node_modules/acorn/dist/acorn.js:1692:19)
    at Parser.pp$3.parseExprOp (/Users/phil/GoogleDrive/go/src/app/frontend/node_modules/acorn/dist/acorn.js:1656:43)
    at Parser.pp$3.parseExprOps (/Users/phil/GoogleDrive/go/src/app/frontend/node_modules/acorn/dist/acorn.js:1639:17)
    at Parser.pp$3.parseMaybeConditional (/Users/phil/GoogleDrive/go/src/app/frontend/node_modules/acorn/dist/acorn.js:1620:21)
    at Parser.pp$3.parseMaybeAssign (/Users/phil/GoogleDrive/go/src/app/frontend/node_modules/acorn/dist/acorn.js:1597:21)
    at Parser.pp$1.parseVar (/Users/phil/GoogleDrive/go/src/app/frontend/node_modules/acorn/dist/acorn.js:1034:28)
    at Parser.pp$1.parseVarStatement (/Users/phil/GoogleDrive/go/src/app/frontend/node_modules/acorn/dist/acorn.js:917:10)
    at Parser.pp$1.parseStatement (/Users/phil/GoogleDrive/go/src/app/frontend/node_modules/acorn/dist/acorn.js:706:19)
    at Parser.pp$1.parseBlock (/Users/phil/GoogleDrive/go/src/app/frontend/node_modules/acorn/dist/acorn.js:981:25)
    at Parser.pp$1.parseStatement (/Users/phil/GoogleDrive/go/src/app/frontend/node_modules/acorn/dist/acorn.js:709:33)
    at Parser.pp$1.parseIfStatement (/Users/phil/GoogleDrive/go/src/app/frontend/node_modules/acorn/dist/acorn.js:824:28)
    at Parser.pp$1.parseStatement (/Users/phil/GoogleDrive/go/src/app/frontend/node_modules/acorn/dist/acorn.js:698:30)
    at Parser.pp$1.parseBlock (/Users/phil/GoogleDrive/go/src/app/frontend/node_modules/acorn/dist/acorn.js:981:25)
    at Parser.pp$3.parseFunctionBody (/Users/phil/GoogleDrive/go/src/app/frontend/node_modules/acorn/dist/acorn.js:2105:24)
    at Parser.pp$3.parseMethod (/Users/phil/GoogleDrive/go/src/app/frontend/node_modules/acorn/dist/acorn.js:2075:10)
    at Parser.pp$1.parseClassMethod (/Users/phil/GoogleDrive/go/src/app/frontend/node_modules/acorn/dist/acorn.js:1137:25)
    at Parser.pp$1.parseClass (/Users/phil/GoogleDrive/go/src/app/frontend/node_modules/acorn/dist/acorn.js:1118:14)
    at Parser.pp$1.parseStatement (/Users/phil/GoogleDrive/go/src/app/frontend/node_modules/acorn/dist/acorn.js:697:19)
 @ ./~/@nivo/voronoi/dist/nivo-voronoi.cjs.js 11:17-39

Если я откатил все пакеты nivo до 0.50, мой проект будет работать нормально. Похоже, это может быть что-то, связанное с https://github.com/plouc/nivo/issues/383 и https://github.com/plouc/nivo/issues/336? Или я испортил ...?

Воспроизвести Webpack:

var path = require('path');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
  entry: ['babel-polyfill', 'whatwg-fetch', 'root.jsx'],
  devtool: 'cheap-source-map',
  // devtool: 'eval',
  output: {
    path: './dist/',
    publicPath: '/dist/',
    sourceMapFilename: "bundle.js.map",
    filename: 'bundle.js'
  },

  resolve: {
    root: path.resolve('./js'),
    extensions: ['', '.js', '.jsx']
  },

  module: {
    loaders: [{
      test: /.jsx?$/,
      loader: 'babel-loader',
      exclude: /node_modules/,
      query: {
        presets: ['es2015', 'react', 'stage-2'],
        plugins: ["transform-decorators-legacy", 'transform-class-properties']
      }
    }, {
      test: /\.scss$/,
      loaders: ['style', 'css', 'sass']
    }, {
      test: /\.(woff|woff2|eot|ttf|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
      loader: 'file-loader?name=fonts/[name]-[hash].[ext]'
    }]
  }
};

Пакет. json

{
  "name": "app",
  "version": "1.0.1",
  "private": true,
  "devDependencies": {
    "babel-core": "^6.26.3",
    "babel-eslint": "^7.1.0",
    "babel-loader": "^6.2.4",
    "babel-plugin-object-assign": "latest",
    "babel-plugin-transform-decorators-legacy": "^1.3.5",
    "babel-polyfill": "^6.13.0",
    "babel-preset-stage-2": "^6.5.0",
    "css-loader": "^3.2.0",
    "eslint-plugin-react": "^5.2.2",
    "file-loader": "^0.8.5",
    "gulp-concat": "latest",
    "html-webpack-plugin": "^2.30.1",
    "imports-loader": "^0.6.5",
    "redux": "^3.5.2",
    "resolve-url-loader": "^1.4.3",
    "sass-loader": "^3.2.0",
    "style-loader": "^0.13.1"
  },
  "dependencies": {
    "@nivo/axes": "^0.61.0",
    "@nivo/core": "^0.61.0",
    "@nivo/legends": "^0.61.1",
    "@nivo/scales": "^0.61.0",
    "@nivo/scatterplot": "^0.61.1",
    "babel-plugin-react-require": "^3.1.3",
    "babel-plugin-transform-class-properties": "^6.24.1",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-react": "^6.24.1",
    "babel-react-require": "^1.0.0",
    "d3-delaunay": "^5.2.1",
    "node-sass": "^4.13.1",
    "prop-types": "^15.6.2",
    "react": "^16.10.2",
    "react-addons-css-transition-group": "^15.4.2",
    "react-bootstrap": "^0.33.0",
    "react-burger-menu": "^2.6.13",
    "react-delay-input": "^4.1.0",
    "react-dom": "^16.5.2",
    "react-redux": "^5.0.7",
    "react-router-bootstrap": "^0.25.0",
    "react-router-dom": "^4.3.1",
    "react-vis": "^1.11.7",
    "redux-watch": "^1.1.1",
    "source-map-explorer": "^2.4.1",
    "twitter-text": "^3.0.0",
    "webpack": "^1.15.0",
    "whatwg-fetch": "^3.0.0"
  },
  "description": "FI Manager",
  "main": "gulpfile.js",
  "scripts": {
    "analyze": "source-map-explorer dist/bundle.js dist/bundle.js.map",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}

...