react-pivot icon indicating copy to clipboard operation
react-pivot copied to clipboard

"You may need an appropriate loader to handle this file type..." for .jsx files

Open HusnuAkcak opened this issue 5 years ago • 3 comments

When I install and compile I am getting this webpack error, what shoul I do? I also tried the suggestions in this link, https://github.com/babel/babel-loader/issues/173

ERROR in ./node_modules/react-pivot/index.jsx 124:6
Module parse failed: Unexpected token (124:6)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| 
|     var html = (
>       <div className='reactPivot'>
| 
|       { this.props.hideDimensionFilter ? '' :

my webpack.config.json file as follows

const path = require("path");
const fs = require("fs");
const CopyPlugin  = require("copy-webpack-plugin");

// Webpack entry points. Mapping from resulting bundle name to the source file entry.
const entries = {};

// Loop through subfolders in the "TimeSheet" folder and add an entry for each one
const timeSheetDir = path.join(__dirname, "src/TimeSheet");
fs.readdirSync(timeSheetDir).filter(dir => {
    if (fs.statSync(path.join(timeSheetDir, dir)).isDirectory()) {
        entries[dir] = "./" + path.relative(process.cwd(), path.join(timeSheetDir, dir, dir));
    }
});

module.exports = {
    entry: entries,
    output: {
        filename: "[name]/[name].js"
    },
    resolve: {
        extensions: [".ts", ".tsx", ".js", ".jsx"],
        alias: {
            "vss-web-extension-sdk": path.resolve("node_modules/vss-web-extension-sdk")
        },
    },
    stats: {
        warnings: false
    },
    module: {
        rules: [
            {
                test: /\.tsx?$/,
                loader: "ts-loader"
            },
            {
                test: /\.jsx?$/,
                exclude: /node_modules/,
                loaders: ['react-hot', 'babel-loader?presets[]=react,presets[]=es2015']
            },
            {
                test: /\.scss$/,
                use: ["style-loader", "css-loader", "azure-devops-ui/buildScripts/css-variables-loader", "sass-loader"]
            },
            {
                test: /\.css$/,
                use: ["style-loader", "css-loader"],
            },
            {
                test: /\.woff$/,
                use: [{
                    loader: 'base64-inline-loader'
                }]
            },
            {
                test: /\.html$/,
                loader: "file-loader"
            }
        ],
    },
    plugins: [
        new CopyPlugin ({
            patterns: [{ from: "**/*.html", context: "src/TimeSheet" }]
        })
    ]
};

HusnuAkcak avatar Jul 27 '20 15:07 HusnuAkcak

add this to your webpack config

  module: {
    rules: [
      {
        test: /\.(js|jsx)$/,
        include: [
          path.join(__dirname, './app'),
          path.join(__dirname, './node_modules', 'react-pivot')
        ],
        use: babelLoader
      },
  ]
}

abdhalees avatar Aug 05 '20 23:08 abdhalees

Hi, I created a fork of this project and modified it to be compatible with Webpack. You can give it a try at https://github.com/ledsoft/react-pivot-webpack.

ledsoft avatar Mar 21 '21 15:03 ledsoft

i cant use this library same issue

dianrp22 avatar Mar 26 '24 05:03 dianrp22