5

我正在使用配置 angularjs 项目依赖项requirejs

以下是配置

"cornerstone-core":"emp/cornerstone.min",
"cornerstone-math":"emp/cornerstoneMath.min",
"hammer":"emp/hammer.min",
"properties":"emp/properties"
"clientParameters":"emp/clientParameters"
"cornerstone":"emp/cornerstone"
"cornerstoneMath":"emp/cornerstoneMath"
"cornerstoneTools":"emp/cornerstoneTools"
"cornerstoneWADOImageLoaderCodecs":"emp/cornerstoneWADOImageLoaderCodecs"
"cornerstoneWADOImageWebWorker":"emp/cornerstoneWADOImageWebWorker"
"myApp":"emp/myApp"

运行时依赖项是,

clientParameters : [ "properties" ],
cornerstoneMath : [ "properties", "clientParameters", "cornerstone-core", "cornerstone-math", "hammerjs" ]
cornerstone : [ "properties", "clientParameters", "cornerstone-core", "cornerstone-math", "hammerjs" ],
cornerstoneTools : [ "properties", "clientParameters", "cornerstone-core", "cornerstone-math", "hammerjs" ],
myApp : [ "properties", "clientParameters", "cornerstone", "cornerstoneMath", "cornerstone-core", "cornerstone-math", "hammerjs" ]

在cornerstone.js 中,我以以下方式加载模块,

(function webpackUniversalModuleDefinition(root, factory) {
  if(typeof exports === 'object' && typeof module === 'object')
    module.exports = factory();
  else if(typeof define === 'function' && define.amd)
    define("cornerstone", [], factory); // error line
  else if(typeof exports === 'object')
    exports["cornerstone"] = factory(); 
  else
    root["cornerstone"] = factory();
})(this, function() {
return (function(modules) {

我收到以下错误,

myApp.js:2312 Uncaught(in promise) ReferenceError: cornerstone is not defined

define("cornerstone", [], factory);
我用一切替换错误行时,root["cornerstone"] = factory();一切正常。

[编辑]
工厂方法是这个问题中使用的引导程序:尝试理解 Webpack

4

1 回答 1

0

因为您使用的是模块,所以首先您必须导入corerstone. 使用 AMD 模块,它看起来像:

define(["angular", "cornerstone"], function (angular, cornerstone) {
    ....
});
于 2018-03-22T22:04:18.580 回答