迁移到webpack 2,找不到模块:错误:无法解决'导出'

时间:2017-08-01 08:29:26

标签: webpack

我正在尝试将当前项目(在Angular2上)迁移到webpack2。 这是我对webpack的配置:

https://gist.github.com/kunashir/5174a237d7404079ebd8f343deee0037

但我有一个错误:

lastName

但是我不使用exports-loader,而不是在webpack1的配置中。

带来错误的模块中的字符串:

ERROR in ./app/common/forms/ckeditor.component.ts
Module not found: Error: Can't resolve 'exports' in 
'/home/al1/projects/voltmobi/ytaxiweb/ui/app/common/forms'
BREAKING CHANGE: It's no longer allowed to omit the '-loader' suffix when using loaders.
             You need to specify 'exports-loader' instead of 'exports',
             see https://webpack.js.org/guides/migrating/#automatic-loader-module-name-extension-removed

导入模块如下:

 import { Constants } from 'config/constants'

我是Webpack的新手。

也许我错了,问题在于:

export class Constants {
  static API = {
    PATH: '/web_api'
  }
}

1 个答案:

答案 0 :(得分:2)

您未在配置中使用exports-loader,但是您指定了inline

let loadCKEDITOR = require('bundle-loader?lazy!exports?window.CKEDITOR!ckeditor/ckeditor')
                                               ^^^^^^^

正如错误所示,这应该是exports-loader

let loadCKEDITOR = require('bundle-loader?lazy!exports-loader?window.CKEDITOR!ckeditor/ckeditor')