babel 7 how to connect polyfill correctly? - reactjs

How to connect polyfill correctly?
I read all the documentation Babel 7 and followed it. Below you can see my settings.
if I add this in the webpack config
entry: [
'core-js/stable',
'regenerator-runtime/runtime',
'./main.js'
],
then everything works. but according to the documentation this line can be removed, since all the settings in the babel.config.js
If i remove from entry this line, redux store not working in IE11
babel.config.js
module.exports = function (api) {
api.cache(true);
return {
presets: [
[
'#babel/preset-env',
{
debug: true,
useBuiltIns: 'entry',
corejs: {
version: '3.6',
proposals: false
},
}
],
'#babel/preset-react',
'rsuite'
],
plugins: [
'react-hot-loader/babel',
'#babel/plugin-proposal-class-properties',
'#babel/plugin-proposal-export-default-from',
'#babel/plugin-proposal-object-rest-spread',
'#babel/plugin-syntax-object-rest-spread',
'#babel/plugin-transform-arrow-functions',
'#babel/plugin-transform-async-to-generator',
'#babel/plugin-transform-classes',
'#babel/plugin-transform-parameters',
'#babel/plugin-transform-property-literals',
['#babel/plugin-transform-runtime',
{
corejs: {
version: 3,
proposals: true
}
}
],
'#babel/plugin-transform-spread',
'#babel/plugin-transform-template-literals',
'babel-plugin-styled-components',
]
};
};
package.json
"devDependencies": {
"#babel/core": "^7.9.0",
"#babel/plugin-proposal-class-properties": "^7.8.3",
"#babel/plugin-proposal-export-default-from": "^7.8.3",
"#babel/plugin-proposal-export-namespace-from": "^7.8.3",
"#babel/plugin-proposal-object-rest-spread": "^7.9.5",
"#babel/plugin-syntax-object-rest-spread": "^7.8.3",
"#babel/plugin-transform-arrow-functions": "^7.8.3",
"#babel/plugin-transform-async-to-generator": "^7.8.3",
"#babel/plugin-transform-classes": "^7.9.5",
"#babel/plugin-transform-parameters": "^7.9.5",
"#babel/plugin-transform-property-literals": "^7.8.3",
"#babel/plugin-transform-runtime": "^7.9.0",
"#babel/plugin-transform-spread": "^7.8.3",
"#babel/plugin-transform-template-literals": "^7.8.3",
"#babel/preset-env": "^7.9.5",
"#babel/preset-react": "^7.9.4",
"#devexpress/dx-react-grid-material-ui": "^2.4.0",
"babel-eslint": "^7.2.3",
"babel-helper-annotate-as-pure": "^7.0.0-beta.3",
"babel-jest": "^23.6.0",
"babel-loader": "^8.0.2",
"babel-plugin-styled-components": "^1.10.7",
"babel-preset-rsuite": "^4.0.1",
"clean-webpack-plugin": "^3.0.0",
"colors": "^1.3.2",
"copy-webpack-plugin": "^4.5.2",
"cross-env": "^5.2.0",
"css-loader": "^3.2.0",
"eslint": "^4.19.1",
"eslint-config-airbnb": "^16.1.0",
"eslint-loader": "^2.1.1",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "^5.1.1",
"eslint-plugin-react": "^7.11.1",
"extract-text-webpack-plugin": "^4.0.0-beta.0",
"file-loader": "^2.0.0",
"html-webpack-plugin": "^3.2.0",
"image-webpack-loader": "^6.0.0",
"less": "^3.8.1",
"less-loader": "^4.1.0",
"mini-css-extract-plugin": "^0.7.0",
"optimize-css-assets-webpack-plugin": "^3.2.1",
"react-highlight-words": "^0.10.0",
"react-hot-loader": "^4.7.2",
"redux-saga": "^0.16.2",
"style-loader": "^0.23.1",
"terser-webpack-plugin": "^1.2.3",
"webpack": "^4.42.1",
"webpack-bundle-analyzer": "^3.6.1",
"webpack-cli": "^3.1.0",
"webpack-dev-server": "^3.1.8"
},
"dependencies": {
"#babel/runtime": "^7.9.2",
"#babel/runtime-corejs3": "^7.9.2",
"#hot-loader/react-dom": "^16.13.0",
"axios": "^0.19.2",
"c3": "0.4.11",
"cookie": "^0.3.1",
"core-js": "^3.6.5",
"date-fns": "^2.0.0",
"file-saver": "^2.0.2",
"jquery": "^3.4.1",
"js-base64": "^2.5.2",
"lodash": "^4.17.11",
"moment": "^2.24.0",
"normalizr": "^3.3.0",
"prop-types": "^15.7.2",
"query-string": "^5.1.1",
"ramda": "^0.26.1",
"rc-tree": "^3.1.1",
"react": "^16.8.3",
"react-datepicker": "^2.8.0",
"react-dom": "^16.8.3",
"react-html-parser": "^2.0.2",
"react-paginate": "^6.3.0",
"react-redux": "^7.1.0-rc.1",
"react-router-dom": "^4.4.0-beta.7",
"react-scrollbar": "^0.5.6",
"react-select": "^2.4.1",
"redux": "^4.0.5",
"redux-devtools-extension": "^2.13.8",
"redux-thunk": "^2.3.0",
"regenerator-runtime": "^0.13.5",
"reselect": "^3.0.1",
"rsuite": "^4.1.4",
"styled-components": "^4.1.3"
}
webpack rules
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: 'babel-loader',
},
{
test: /\.css$/,
use: cssLoaders()
},
{
test: /\.less$/,
exclude: /node_modules/,
use: cssLoaders('less-loader')
},
{
test: /\.(png|jpg|svg|gif?)$/,
use: 'file-loader'
},
{
test: /\.(woff|woff2|eot|ttf|otf?)$/,
use: 'file-loader'
},
]
},

Just don't remove these lines you've added for the polyfills
entry: [
'core-js/stable',
'regenerator-runtime/runtime',
'./main.js'
],
You are doing right, give us the link to the documentation where it is said this line can be removed. I think it's a misunderstanding.
Or maybe you are missing an other babel plugin ;)
UPDATE 2020-04-17
As it is said for #babel-polyfill
As of Babel 7.4.0, this package has been deprecated in favor of directly including core-js/stable (to polyfill ECMAScript features) and regenerator-runtime/runtime (needed to use transpiled generator functions):
So install npm i core-js and npm i regenerator-runtime
Then in your webpack config file you manage the entry points like that
...
entry: {
bundle: [require.resolve('core-js/stable'), require.resolve('regenerator-runtime/runtime'), paths.srcClient]
},
...
Then you are good to go

I think this is due to the fact that the react does not support ie10. I get an error in ie10 Set in undefined and in ie11 the redux store is not loaded. According to the documentation, the react needs to be imported polyfill globally.
https://reactjs.org/docs/javascript-environment-requirements.html

Related

Module build failed (from ./node_modules/eslint-loader/dist/cjs.js): TypeError: Cannot read properties of undefined (reading 'getFormatter')

I am running a simple React/Django app with webpack that is receiving this error on build:
ERROR in ./src/index.js
Module build failed (from ./node_modules/eslint-loader/dist/cjs.js):
TypeError: Cannot read properties of undefined (reading 'getFormatter')
at getFormatter (**[Relative path]**/frontend/node_modules/eslint-loader/dist/getOptions.js:52:20)
at getOptions (**[Relative path]**/frontend/node_modules/eslint-loader/dist/getOptions.js:30:23)
at Object.loader (**[Relative path]**/frontend/node_modules/eslint-loader/dist/index.js:17:43)
Here's my package.json
{
"name": "frontend",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start:dev": "webpack serve --config webpack.config.dev.js --port 3000",
"clean:build": "rimraf ../static && mkdir ../static",
"prebuild": "run-p clean:build",
"build": "webpack --config webpack.config.prod.js",
"postbuild": "rimraf ../static/index.html"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"axios": "^0.24.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-redux": "^7.2.6",
"redux": "^4.1.2",
"redux-thunk": "^2.4.0",
"reselect": "^4.1.1"
},
"devDependencies": {
"#babel/core": "^7.16.0",
"#babel/node": "^7.16.0",
"#babel/preset-env": "^7.16.0",
"#babel/preset-react": "^7.16.0",
"babel-eslint": "^10.1.0",
"babel-loader": "^8.2.3",
"babel-polyfill": "^6.26.0",
"css-loader": "^6.5.0",
"cssnano": "^5.0.9",
"eslint": "^8.1.0",
"eslint-loader": "^4.0.2",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-react": "^7.26.1",
"eslint-plugin-react-hooks": "^4.2.0",
"html-webpack-plugin": "^5.5.0",
"mini-css-extract-plugin": "^2.4.3",
"npm-run-all": "^4.1.5",
"postcss-loader": "^6.2.0",
"redux-immutable-state-invariant": "^2.1.0",
"rimraf": "^3.0.2",
"style-loader": "^3.3.1",
"webpack": "^5.61.0",
"webpack-cli": "^4.9.1",
"webpack-dev-server": "^4.4.0"
}
}
And my webpack.config.dev.js
const webpack = require('webpack');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
process.env.NODE_ENV = 'development';
module.exports = {
mode: 'development',
target: 'web',
devtool: 'cheap-module-source-map',
entry: ['babel-polyfill', './src/index'],
output: {
path: path.resolve(__dirname),
publicPath: '/',
filename: 'bundle.js'
},
devServer: {
// stats: 'minimal',
client: {
overlay: true
},
historyApiFallback: true,
// disableHostCheck: true,
headers: { 'Access-Control-Allow-Origin': '*' },
https: false
},
plugins: [
new webpack.DefinePlugin({
'process.env.API_URL': JSON.stringify('http://localhost:8000/api/')
}),
new HtmlWebpackPlugin({
template: './src/index.html',
favicon: './src/favicon.ico'
})
],
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader'
},
'eslint-loader'
]
},
{
test: /(\.css)$/,
use: ['style-loader', 'css-loader']
}
]
}
};
Unsure if I need to make changes to my config file or if it's an issue with a package I have installed. Any guidance would be helpful as I am not very familiar with webpack's inner workings.
Versions:
node: v17.0.1
npm: 8.1.2
python: 3.9.6 (pretty sure it's a js/webpack issue)
Django: 3.2.8 (^^^)
eslint-loader is deprecated:
https://www.npmjs.com/package/eslint-loader
You may use eslint-webpack-plugin instead:
https://www.npmjs.com/package/eslint-webpack-plugin
I found an issue https://github.com/webpack-contrib/eslint-loader/issues/331 about this in the eslint-loader github, but I don't know if it will be useful for you.
. It would help to have a git repository to store the code that would be wrong for better testing. :)
"dependencies": {
"axios": "^0.24.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-redux": "^7.2.6",
"react-router-dom": "^6.0.1",
"redux": "^4.1.2",
"redux-thunk": "^2.4.0",
"reselect": "^4.1.1"
},
"devDependencies": {
"#babel/core": "^7.15.0",
"#babel/node": "^7.14.9",
"#babel/preset-env": "^7.15.0",
"#babel/preset-react": "^7.14.5",
"babel-eslint": "^10.1.0",
"babel-loader": "^8.2.2",
"babel-polyfill": "^6.26.0",
"css-loader": "^6.2.0",
"cssnano": "^5.0.7",
"eslint": "^7.32.0",
"eslint-loader": "^4.0.2",
"eslint-plugin-import": "^2.24.0",
"eslint-plugin-react": "^7.24.0",
"eslint-plugin-react-hooks": "^4.2.0",
"html-webpack-plugin": "^5.3.2",
"mini-css-extract-plugin": "^2.2.0",
"npm-run-all": "^4.1.5",
"postcss-loader": "^6.1.1",
"redux-immutable-state-invariant": "^2.1.0",
"rimraf": "^3.0.2",
"style-loader": "^3.2.1",
"webpack": "^5.50.0",
"webpack-cli": "^4.8.0",
"webpack-dev-server": "^3.11.2"
}
I reverted back to these versions (a past project worked on them) and it is now working properly. I believe it has something to do with eslint and eslint-loader.
eslint-loader has been deprecated now, and i change to use eslint-webpack-plugin which really works now!! I am so greatful, this problem has been troubling me a lot!
It really solve my problem thanks to the top answer, but I cannot comment directly on that answer due to my low reputation.
In addition, this is a plugin rather than loader, so you should add it to plugins and don't forget to "new".enter link description here
Find out that my versions of eslint and eslint-loader were incompatible
those works for me
"eslint": "^7.32.0",
"eslint-loader": "^4.0.2",

SCRIPT1028: SCRIPT1028: Expected identifier, string or number

I am working on an React App, and I can not open this app in Safari and IE.
For IE-11: SCRIPT1028: SCRIPT1028: Expected identifier, string or number
For Safari(10.1.2) : SyntaxError: Unexpected token '...'. Expected a property name.
my package.json file is as..
"dependencies": {
"#babel/core": "^7.0.0",
"#babel/plugin-proposal-object-rest-spread": "^7.6.2",
"#storybook/addon-backgrounds": "^3.4.8",
"#storybook/react": "^4.0.0-alpha.4",
"#types/d3": "^5.0.0",
"#types/debug": "^0.0.30",
"#types/enzyme": "^3.1.9",
"#types/jest": "^23.1.4",
"#types/moment-timezone": "^0.5.4",
"#types/react": "^16.9.11",
"#types/react-dom": "^16.9.3",
"#types/react-intl": "^2.3.16",
"#types/react-mentions": "2.4.0",
"#types/react-redux": "^7.1.5",
"#types/react-router": "^5.1.2",
"#types/react-router-dom": "^5.1.0",
"#types/react-select": "^1.2.6",
"#types/react-show-more": "^2.0.1",
"#types/reactour": "^1.13.1",
"#types/redux": "^3.6.0",
"#types/redux-form": "^7.3.1",
"#types/redux-logger": "^3.0.6",
"#types/storybook__addon-backgrounds": "^3.2.0",
"#types/storybook__react": "^3.0.8",
"#types/styled-components": "^4.1.19",
"awesome-typescript-loader": "^5.2.0",
"axios": "^0.18.0",
"babel-engine-plugin": "^0.3.0",
"babel-loader": "^7.0.0",
"babel-register": "^6.26.0",
"connected-react-router": "^4.4.1",
"cosed": "^1.1.8",
"d3": "^5.7.0",
"date-fns": "^1.29.0",
"debug": "^3.1.0",
"duplicate-package-checker-webpack-plugin": "^3.0.0",
"emoji-mart": "^2.6.1",
"enzyme": "^3.3.0",
"enzyme-adapter-react-16": "^1.1.1",
"gen-tester": "^3.1.2",
"history": "^4.10.1",
"html-loader": "^0.5.5",
"html-webpack-plugin": "^3.1.0",
"husky": "^0.14.3",
"immer": "^1.3.1",
"jest": "^23.3.0",
"jest-environment-enzyme": "^6.0.2",
"jest-enzyme": "^6.0.2",
"jest-styled-components": "^6.0.0",
"lint-staged": "^7.2.0",
"moment-timezone": "^0.5.14",
"prettier": "^1.13.7",
"prop-types": "^15.7.2",
"react": "^16.11.0",
"react-cosed": "^1.0.9",
"react-dom": "^16.11.0",
"react-intl": "^2.8.0",
"react-redux": "^5.1.1",
"react-router": "^5.1.2",
"react-router-dom": "^5.1.2",
"react-select": "^1.2.1",
"reactour": "^1.15.4",
"redux": "^4.0.0",
"redux-cosed": "^1.0.1",
"redux-form": "^8.2.6",
"redux-persist": "^5.10.0",
"redux-thunk": "^2.3.0",
"styled-components": "^4.4.1",
"ts-jest": "^23.0.0",
"tslint": "^5.9.1",
"tslint-config-prettier": "^1.13.0",
"tslint-no-circular-imports": "^0.5.0",
"typescript": "^3.0.1",
"uglifyjs-webpack-plugin": "^1.2.7",
"url-loader": "^1.0.1",
"webpack": "^4.15.1",
"webpack-cli": "^3.0.8",
"webpack-dev-server": "^3.1.5",
"webpack-merge": "^4.1.3"
},
"devDependencies": {
"#types/lodash.debounce": "^4.0.4",
"firebase-tools": "^6.1.0",
"lodash.debounce": "^4.0.8"
}
If some more details needed please let me know.
Please suggest, what do i need to do.... Thanks
My webpack.js file is as....
const path = require('path');
const HtmlWebPackPlugin = require('html-webpack-plugin');
const {
CheckerPlugin,
TsConfigPathsPlugin,
} = require('awesome-typescript-loader');
const DuplicatePackageCheckerPlugin = require('duplicate-package-checker-webpack-plugin');
const ROOT = path.resolve(__dirname, '..');
module.exports = {
module: {
rules: [
{
test: /.tsx?$/,
use: 'awesome-typescript-loader',
exclude: /node_modules/,
},
{
test: /.(png|jpg|gif|svg)$/,
use: [
{
loader: 'url-loader',
options: {
limit: 25000,
},
},
],
},
{
test: /.html$/,
use: 'html-loader',
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
modules: [path.resolve(ROOT, 'shared'), 'node_modules'],
plugins: [new TsConfigPathsPlugin()],
},
plugins: [
new HtmlWebPackPlugin({
template: path.join(ROOT, 'shared', 'index.html'),
filename: './index.html',
}),
new CheckerPlugin(),
new DuplicatePackageCheckerPlugin(),
],
};
I think babel-loader will work but can't find any way to use babel-loader. I need this app to run on ie11 and safari as well.
Please suggest some solution...
The issue is that by default the application was being rendered on IE7, that is - not on IE11/Edge that supports the transpiled build. So I had to mention the meta information to let the browser know that the intended browser is IE11/Edge. Add this to the head section of your index.html:
<meta http-equiv="X-UA-Compatible" content="IE=edge">
Now you might be getting some errors in the console that read SCRIPT5009: 'Set' is undefined - refer to the below link relating to polyfills for the Set collection type:
React JavaScript Environment Requirements
For more information on the issue see:
React app not rendering in IE11 and below
Because you are opening it in Microsoft edge, try opening it in latest chrome version... problem will be solved.....this works for ReactJs projects

Babel 7 spread syntax in IE/Edge not working

So i have babel 7 installed, along with the plugin "#babel/plugin-proposal-object-rest-spread" included within my preset-env, however I'm still getting the following error as it hasn't transpiled my spread operators back into es2015.
SCRIPT1028: Expected identifier, string or number
I've tried referencing the plugin in the plugin array within my .babelrc file.
My .babelrc file:
{
"presets": [
"#babel/preset-react",
"#babel/preset-env", {
"include": [
"#babel/plugin-proposal-object-rest-spread"
]
}
],
"plugins": [
"#babel/plugin-syntax-dynamic-import",
"#babel/plugin-syntax-import-meta",
"#babel/plugin-proposal-class-properties",
"#babel/plugin-proposal-json-strings",
]
}
My package.json dependencies/dev dependencies:
"dependencies": {
"#babel/polyfill": "^7.2.5",
"axios": "^0.18.0",
"babel-polyfill": "^6.26.0",
"bootstrap": "^4.1.3",
"core-js": "^2.6.3",
"dotenv": "^6.1.0",
"get-base64": "^1.3.0",
"history": "^4.7.2",
"moment": "^2.22.2",
"prop-types": "^15.6.2",
"qs": "^6.5.2",
"react": "^16.6.0",
"react-debounce-input": "^3.2.0",
"react-dom": "^16.6.0",
"react-onclickoutside": "^6.7.1",
"react-redux": "^5.1.0",
"react-router-dom": "^4.3.1",
"react-router-redux": "^4.0.8",
"react-select": "^2.1.2",
"redux": "^4.0.1",
"redux-devtools-extension": "^2.13.5",
"redux-thunk": "^2.3.0",
"svg-url-loader": "^2.3.2",
"webpack": "^4.23.1",
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.1.14",
"webpack-merge": "^4.1.4"
},
"devDependencies": {
"#babel/core": "^7.0.0",
"#babel/plugin-proposal-class-properties": "^7.0.0",
"#babel/plugin-proposal-json-strings": "^7.0.0",
"#babel/plugin-proposal-object-rest-spread": "^7.3.1",
"#babel/plugin-syntax-dynamic-import": "^7.0.0",
"#babel/plugin-syntax-import-meta": "^7.0.0",
"#babel/preset-env": "^7.0.0",
"#babel/preset-react": "^7.0.0",
"babel-eslint": "^9.0.0",
"babel-loader": "^8.0.0",
"babel-plugin-transform-es2015-destructuring": "^6.23.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"copy-webpack-plugin": "^4.6.0",
"css-loader": "^1.0.0",
"eslint": "^5.8.0",
"eslint-config-airbnb": "^17.1.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "^6.1.2",
"eslint-plugin-react": "^7.11.1",
"file-loader": "^2.0.0",
"html-webpack-plugin": "^3.2.0",
"interpolate-html-plugin": "^3.0.0",
"node-sass": "^4.9.4",
"optimize-css-assets-webpack-plugin": "^5.0.1",
"sass-loader": "^7.1.0",
"style-loader": "^0.23.1",
"uglify-es-webpack-plugin": "^0.10.0",
"url-loader": "^1.1.2"
Looks like you're using Webpack, and you have babel-loader installed.
That being the case, here are two quick things to check:
Are you sure you're using that loader in your webpack config for js files?
rules: [
{
test: /\.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
},
],
Are there any js assets bypassing Webpack, "missing out" on that loader?
(Edit): And if "no" to those, might you also need "#babel/plugin-transform-spread" to capture spreads in an array, since "#babel/plugin-proposal-object-rest-spread" is object-specific?

Webpack 1.15.0 Parse Error: JSX File

I have tried to fix my errors according to some answers. But I can't solve.
I am using webpack 1.15.0 and babel-loader 6.4.1.
Please help me to parse jsx file.
Here is the error message.
ERROR in ./~/react-file-viewer/src/components/file-viewer.jsx Module
parse failed:
E:\code-bucket\university\node_modules\react-file-viewer\src\components\file-viewer.jsx
Unexpected token (74:6) You may need an appropriate loader to handle
this file type. SyntaxError: Unexpected token (74:6)
Here is my webpack.config.js file.
{
var path = require('path');
module.exports = {
entry: './client/js/app.js',
output: {
path: path.resolve('www/build/js'),
filename: 'app.bundle.js',
pathinfo: false
},
module: {
loaders: [
{
test: /\.(js|jsx)$/,
loader: 'babel-loader',
query: {
presets: ['es2015', 'react'],
plugins: ['transform-object-rest-spread']
},
exclude: /node_modules/
},
{
test: /\.css$/, // Transform all .css files required somewhere within an entry point...
loaders: ['style-loader', 'css-loader', 'postcss-loader'] // ...with PostCSS
}
]
},
postcss: function() {
return [
require('postcss-import')({ // Import all the css files...
onImport: function (files) {
files.forEach(this.addDependency); // ...and add dependecies from the main.css files to the other css files...
}.bind(this) // ...so they get hot–reloaded when something changes...
}),
require('postcss-simple-vars')(), // ...then replace the variables...
require('postcss-focus')(), // ...add a :focus to ever :hover...
require('autoprefixer')({ // ...and add vendor prefixes...
browsers: ['last 2 versions', 'IE > 8'] // ...supporting the last 2 major browser versions and IE 8 and up...
}),
require('postcss-reporter')({ // This plugin makes sure we get warnings in the console
clearMessages: true
})
];
},
target: "web", // Make web variables accessible to webpack, e.g. window
stats: {
colors: true
},
devtool: 'source-map'
};
}
Here is my package.json file.
{
"name": "university",
"version": "1.0.0",
"description": "Sample Application with React and the Lightning Design System",
"engines": {
"node": "4.2.1"
},
"main": "server.js",
"scripts": {
"webpack": "webpack",
"start": "node server.js",
"bundle": "build-bundle src/apps/ -o dist -v 1.0.0"
},
"author": "Christophe Coenraets <ccoenraets#gmail.com> (http://coenraets.org/)",
"license": "ISC",
"dependencies": {
"autoprefixer": "^7.1.4",
"babel-plugin-transform-object-rest-spread": "^6.3.13",
"bcryptjs": "^2.4.3",
"body-parser": "^1.14.2",
"build-bundle": "^2.0.8",
"compression": "^1.6.1",
"connect-busboy": "0.0.2",
"connect-multiparty": "^2.0.0",
"css-loader": "^0.28.7",
"cssnano": "^3.10.0",
"express": "^4.13.4",
"file-loader": "^0.11.2",
"filesize": "^3.5.10",
"fine-uploader": "^5.15.0",
"fontfaceobserver": "^2.0.13",
"fs": "0.0.1-security",
"fs-extra": "^4.0.2",
"gulp": "^3.9.1",
"json2csv": "^3.11.4",
"loader-utils": "^1.1.0",
"method-override": "^2.3.5",
"moment": "^2.11.2",
"multer": "^1.3.0",
"mysql": "^2.14.1",
"object.assign": "^4.0.4",
"path": "^0.12.7",
"pg": "^4.4.4",
"postcss-cssnext": "^3.0.2",
"postcss-focus": "^2.0.0",
"postcss-import": "^11.0.0",
"postcss-loader": "^2.0.6",
"postcss-reporter": "^5.0.0",
"react-addons-css-transition-group": "^15.6.2",
"react-addons-transition-group": "^15.6.2",
"react-animate-height": "^0.10.3",
"react-bootstrap": "^0.31.3",
"react-csv": "^1.0.8",
"react-file-download": "^0.3.5",
"react-file-viewer": "^0.3.48",
"react-fileupload": "^2.4.0",
"react-fine-uploader": "^1.0.7",
"react-html-table-to-excel": "^2.0.0",
"react-redux": "^5.0.6",
"react-router": "^2.0.0-rc5",
"react-strap": "0.0.1",
"react-swipeable-views": "^0.12.8",
"react-transition-group": "^2.2.1",
"react-upload-file": "^2.0.0-beta.6",
"reactstrap": "^4.8.0",
"reactstrap-tether": "^1.3.4",
"redux": "^3.7.2",
"redux-thunk": "^2.2.0",
"sass": "^1.0.0-beta.2",
"style-loader": "^0.18.2",
"write": "^1.0.3",
"write-file": "^1.0.0",
"write-file-p": "^1.0.6"
},
"devDependencies": {
"babel-core": "^6.4.5",
"babel-loader": "^6.4.1",
"babel-preset-es2015": "^6.3.13",
"babel-preset-react": "^6.3.13",
"babel-preset-stage-3": "^6.3.13",
"history": "^1.17.0",
"postcss": "^6.0.12",
"postcss-simple-vars": "^4.1.0",
"react": "^0.14.9",
"react-addons-linked-state-mixin": "^0.14.7",
"react-dom": "^0.14.9",
"react-onclickoutside": "^4.5.0",
"react-router": "^1.0.3",
"webpack": "^1.15.0"
}
}

Babel failes to compile plugin it should be ignoring

Trying to compile my code with the webpack loader which i have set to ignore node_modules and have not been able to bypass the error below. I've tried clearing out my node_modules and reinstalling as well as adding and removing packages but have been unable to clear the block:
/home/mgarf/Documents/testApp/node_modules/babel-plugin- transform-react-jsx/lib/index.js:16
var visitor = require("babel-helper-builder-react-jsx")({ /*istanbul ignore next*/
^
TypeError: require(...) is not a function
at exports.default (index.js:14:17)
at Function.memoisePluginContainer (/home/mgarf/Documents/testApp/node_modules/babel-core/lib/transformation/file/options/option-manager.js:134:13)
at Function.normalisePlugin (/home/mgarf/Documents/testApp/node_modules/babel-core/lib/transformation/file/options/option-manager.js:168:32)
at /home/mgarf/Documents/testApp/node_modules/babel-core/lib/transformation/file/options/option-manager.js:208:30
at Array.map (native)
at Function.normalisePlugins (/home/mgarf/Documents/testApp/node_modules/babel-core/lib/transformation/file/options/option-manager.js:180:20)
at OptionManager.mergeOptions (/home/mgarf/Documents/testApp/node_modules/babel-core/lib/transformation/file/options/option-manager.js:300:36)
at /home/mgarf/Documents/testApp/node_modules/babel-core/lib/transformation/file/options/option-manager.js:371:14
at /home/mgarf/Documents/testApp/node_modules/babel-core/lib/transformation/file/options/option-manager.js:392:24
at Array.map (native)
Here is my webpackconfig snippet.
var webpack = require('webpack');
require('style-loader');
require('css-loader');
require('babel-register')({
ignore: /\.css$/,
});
...
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
plugins: [
['react-transform', {
transforms: [
{
transform: 'react-transform-hmr',
imports: ['react'],
locals: ['module']
}, {
transform: 'react-transform-catch-errors',
imports: ['react', 'redbox-react']
}
]
}]
]
}
},
{ test: /\.css$/, exclude: /node_modules/, loader: "style-loader!css-loader" }
]
}
and package.json:
"dependencies": {
"async": "^1.5.2",
"bcrypt-nodejs": "^0.0.3",
"body-parser": "^1.15.1",
"bookshelf": "^0.10.0",
"compression": "^1.6.2",
"cookie-parser": "^1.4.1",
"dotenv": "^2.0.0",
"express": "^4.13.4",
"express-validator": "^2.20.4",
"jsonwebtoken": "^5.7.0",
"knex": "^0.11.7",
"moment": "^2.12.0",
"morgan": "^1.7.0",
"mysql": "^2.10.2",
"nodemailer": "^2.3.0",
"nunjucks": "^2.4.1",
"react": "^15.2.1",
"react-cookie": "^0.4.5",
"react-dom": "^15.2.1",
"react-redux": "^4.4.5",
"react-router": "^2.4.0",
"react-transform-catch-errors": "^1.0.2",
"react-transform-hmr": "^1.0.4",
"redbox-react": "^1.2.4",
"redux": "^3.3.1",
"redux-thunk": "^2.0.1",
"request": "^2.69.0",
"webpack": "^1.12.14",
"webpack-dev-middleware": "^1.6.1",
"webpack-hot-middleware": "^2.10.0",
"whatwg-fetch": "^0.11.0"
},
"devDependencies": {
"babel-core": "^6.7.2",
"babel-loader": "^6.2.4",
"babel-plugin-react-transform": "^2.0.2",
"babel-polyfill": "^6.7.2",
"babel-preset-es2015": "^6.6.0",
"babel-preset-react": "^6.5.0",
"babel-plugin-react-transform": "^2.0.0-beta1",
"babel-plugin-rewire": "^1.0.0-rc-3",
"babel-plugin-transform-export-extensions": "^6.8.0",
"babel-register": "^6.8.0",
"chai": "^3.5.0",
"css-loader": "^0.23.1",
"enzyme": "^2.3.0",
"fetch-mock": "3.0.2",
"mocha": "^2.4.5",
"react-addons-test-utils": "^15.0.2",
"react-date-picker": "^5.3.21",
"redux-mock-store": "^1.0.2",
"sinon": "^1.17.3",
"sinon-chai": "^2.8.0",
"style-loader": "^0.13.1",
"supertest": "^1.2.0"
},
"engines": {
"node": "6.1.0"
}
}

Resources