0

I'm trying to print the project, but I can't create a webpack. I have used devextreme objects in the project I need to make settings related to this?

Hash: 79a2ea44e6cd4deb6dd7
Version: webpack 4.29.5
Time: 1885ms
Built at: 2019-03-01 10:44:41
     Asset      Size  Chunks             Chunk Names
 bundle.js  6.62 KiB    main  [emitted]  main
index.html  1.65 KiB          [emitted]
Entrypoint main = bundle.js
[./src/index.js] 2.49 KiB {main} [built] [failed] [1 error]

ERROR in ./src/index.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: Plugin/Preset files are not allowed to export objects, only functions. In C:\Users\takgu\Desktop\react-test\node_modules\babel-preset-stage-0\lib\index.js    at createDescriptor (C:\Users\takgu\Desktop\react-test\node_modules\@babel\core\lib\config\config-descriptors.js:178:11)
    at items.map (C:\Users\takgu\Desktop\react-test\node_modules\@babel\core\lib\config\config-descriptors.js:109:50)
    at Array.map (<anonymous>)
    at createDescriptors (C:\Users\takgu\Desktop\react-test\node_modules\@babel\core\lib\config\config-descriptors.js:109:29)
    at createPresetDescriptors (C:\Users\takgu\Desktop\react-test\node_modules\@babel\core\lib\config\config-descriptors.js:101:10)
    at presets (C:\Users\takgu\Desktop\react-test\node_modules\@babel\core\lib\config\config-descriptors.js:47:19)
    at mergeChainOpts (C:\Users\takgu\Desktop\react-test\node_modules\@babel\core\lib\config\config-chain.js:320:26)
    at C:\Users\takgu\Desktop\react-test\node_modules\@babel\core\lib\config\config-chain.js:283:7
    at buildRootChain (C:\Users\takgu\Desktop\react-test\node_modules\@babel\core\lib\config\config-chain.js:120:22)
    at loadPrivatePartialConfig (C:\Users\takgu\Desktop\react-test\node_modules\@babel\core\lib\config\partial.js:85:55)
    at Object.loadPartialConfig (C:\Users\takgu\Desktop\react-test\node_modules\@babel\core\lib\config\partial.js:110:18)
    at Object.<anonymous> (C:\Users\takgu\Desktop\react-test\node_modules\babel-loader\lib\index.js:140:26)
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (C:\Users\takgu\Desktop\react-test\node_modules\babel-loader\lib\index.js:3:103)
    at _next (C:\Users\takgu\Desktop\react-test\node_modules\babel-loader\lib\index.js:5:194)
    at C:\Users\takgu\Desktop\react-test\node_modules\babel-loader\lib\index.js:5:364
    at new Promise (<anonymous>)
    at Object.<anonymous> (C:\Users\takgu\Desktop\react-test\node_modules\babel-loader\lib\index.js:5:97)
    at Object._loader (C:\Users\takgu\Desktop\react-test\node_modules\babel-loader\lib\index.js:220:18)
    at Object.loader (C:\Users\takgu\Desktop\react-test\node_modules\babel-loader\lib\index.js:56:18)
    at Object.<anonymous> (C:\Users\takgu\Desktop\react-test\node_modules\babel-loader\lib\index.js:51:12)
Child html-webpack-plugin for "index.html":
     1 asset
    Entrypoint undefined = index.html
    [./node_modules/html-webpack-plugin/lib/loader.js!./public/index.html] 1.85 KiB {0} [built]
    [./node_modules/webpack/buildin/global.js] (webpack)/buildin/global.js 475 bytes {0} [built]
    [./node_modules/webpack/buildin/module.js] (webpack)/buildin/module.js 546 bytes {0} [built]
        + 1 hidden module

I have read and applied documents related to webpack settings but I could not get rid of the error. I have shared the contents of webpack.config.js below.

var path=require("path"); //dosya yolunu alabilmek için kütüphanesini ekledik.
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports={
    entry:'./src/index.js', //paketlenip tek bir dosya haline gelecek dosyayı belirtiyoruz yani en baş dosya
    output:{
        path:path.resolve(__dirname,'bundle'), // çıkacak olan dosyanın nerede çıkması gerektiğini gösteriyoruz
        filename:'bundle.js' //çıkacak dosyanın adını belirtiyoruz
    },
    mode:'development', //burada production der isek çıkan dosya okunmaz bir şekilde çıktı verir fakat development der isek okunmayacak şekilde sıkıştırarak çıktı verir
    module:{
        rules:[
            {
                test:/\.js$/,
                exclude:'/node_modules/',
                loaders:['babel-loader'],

            },
            { test: /\.css$/, use: ['style-loader', 'css-loader'] },
            { test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: 'file-loader' },
            { test: /\.(woff|woff2)$/, loader: 'url-loader?prefix=font/&limit=5000' },
            {
              test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
              loader: 'url-loader?limit=10000&mimetype=application/octet-stream'
            },
            {
              test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
              issuer: {
                test: /\.jsx?$/
              },
              use: ['babel-loader', '@svgr/webpack', 'url-loader']
            },
            {
              test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
              loader: 'url-loader'
            },
            {
              test: /\.png(\?v=\d+\.\d+\.\d+)?$/,
              loader: 'url-loader?limit=10000&mimetype=image/png'
            },
            {
              test: /\.gif(\?v=\d+\.\d+\.\d+)?$/,
              loader: 'url-loader?limit=10000&mimetype=image/gif'
            }
        ]
    },
    plugins: [
        new HtmlWebpackPlugin({
          template: 'public/index.html'
        })
      ]
};

I shared the settings of .babelrc file here

{
  "presets": ["env", "stage-0", "react","es2015"],
  "plugins": [
      "transform-decorators-legacy"
  ]
}

I'm waiting for your help.

hitmanche
  • 23
  • 4

1 Answers1

0

I've only just started teaching myself programming so I may be wrong but as far as I'm aware when babel upgraded from babel 6 to babel 7 they made several breaking changes. They made babel much more modular an hence why you have to import from @babel/"plugin name".

I strongly suggest you take a look at https://babeljs.io/docs/en/v7-migration for more details.

They also changed the way that stage-presets work. So your "stage-0" no-longer works. Instead you have to import the plugin for each experimental feature you wish to transpile.

This may not be the source of your error but it's at least a place to start. Let me know how you get on.

Michael Knight
  • 265
  • 3
  • 9
  • When you say yes, you're right. After upgrading the babel version and making settings, my issue has improved. [link](https://stackoverflow.com/questions/49182862/preset-files-are-not-allowed-to-export-objects) Here I made some changes by applying the solutions and the problem disappeared. Thank you for your answer. – hitmanche Mar 01 '19 at 09:29