所以我最近升級到了一個React應用程序的webpack 2。它直接從盒子裏運行,沒有我改變任何東西,但版本號!大。Webpack 2遷移中斷ES6模塊導入
但是,現在我試圖讓它爲我捆綁ES6模塊(導入,導出等),並且babel和webpack似乎沒有很好地協作。
我所做的唯一變化,試圖完成,這是我的.babelrc
從:
{
"presets": ["es2015", "stage-1", "react"],
"plugins": ["transform-object-rest-spread"],
}
這樣:
{
"presets": [["es2015", {"modules": false}], "stage-1", "react"],
"plugins": ["transform-object-rest-spread"],
}
的WebPack仍然捆綁這件事而不發出一個錯誤,但是當我打開應用程序,我得到了可怕的"Warning: React.createElement: type should not be null, undefined, boolean, or number. It should be a string (for DOM elements) or a ReactClass (for composite components)."
堆棧跟蹤把我帶回到我的應用程序的第一行(ReactDOM.render(...
)
從我所看到的這個錯誤,當您嘗試使用import { Component } from './component.js'
而非import Component from './component.js'
導入其他組件的默認出口通常出現。雖然我不明白爲什麼會出現這種情況,因爲我知道我的代碼與babel一起編譯它。
任何提示?