Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 508395

Summary: CodeEdit: Webpack complains the code from "marked/marked".
Product: [ECD] Orion Reporter: libing wang <libingw>
Component: EditorAssignee: libing wang <libingw>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 12.0   
Target Milestone: 13.0   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description libing wang CLA 2016-11-29 11:04:51 EST
End user who is trying to build their app with webpack found errors described as below:
In built-codeEdit.js, the declare of module orion/hover is wrote as below:

if (typeof exports === 'object') {
 module.exports = marked;
} else if (typeof define === 'function' && define.amd) {
 define('marked/marked',[],function() { return marked; });
} else {
 this.marked = marked;
}

But when I import the js, there  will be error


After I change it to :
if (typeof define === 'function' && define.amd) {
 define('marked/marked',[],function() { return marked; });
}
else if (typeof exports === 'object') {
 module.exports = marked;
} else {
 this.marked = marked;
}

everything is OK. So the amd should be checked first. I see other places amd are always checked first.
Comment 1 libing wang CLA 2016-11-29 11:05:52 EST
The source code comes from https://github.com/chjj/marked/blob/master/lib/marked.js
Comment 2 libing wang CLA 2016-11-30 15:45:34 EST
In Orion code base, the deferred.js has the similar pattern of code:

    if (typeof define === "function" && define.amd) { //$NON-NLS-0$
        define(factory);
    } else if (typeof exports === "object") { //$NON-NLS-0$
        module.exports = factory();
    } else {
        root.orion = root.orion || {};
        root.orion.Deferred = factory();
    }