如何在 StealJS 中重新定位 CommonJS 模块

How to Repath CommonJS modules in StealJS

我可能做错了什么,所以请随时质疑所有事情。我正在为 MS CRM 模拟框架使用 npm 包 xrm-mock。我已经这样设置了我的配置

steal.config({
    meta: {
        "dependencyModule": {
            deps: [
                /***********************************
                 *  List of Spec Files goes here!  *
                 ***********************************/
                "spec/po_/commonSpec"
                ,"spec/xrmMockGeneratorSpec"
            ]
        },
        "jasmine": {
            "exports":  "jasmineRequire"
        },
        "jasmine-html": {
            deps: ["jasmine"]
        },
        "jasmine-boot": {
            deps: ["jasmine", "jasmine-html"]
        },
        "xrm-mock-generator": {
            deps: ["xrm-mock"]
        }
    },
    bundlesPath: "../WebResources",
    loadBundles: true,
    paths: {
        "jasmine": "../node_modules/jasmine-core/lib/jasmine-core/jasmine.js",
        "jasmine-html": "../node_modules/jasmine-core/lib/jasmine-core/jasmine-html.js",
        "jasmine-boot": "../node_modules/jasmine-core/lib/jasmine-core/boot.js",
        "sourcemapped-stacktrace": "../node_modules/sourcemapped-stacktrace/dist/sourcemapped-stacktrace.js",
        "xrm-mock": "../node_modules/xrm-mock/index.js",
        "xrm-mock-generator": "../node_modules/xrm-mock-generator/dist/xrm-mock-generator.js"
    },
    map: {},
    main: "./testRunner"
});

但是 xrm-mock/index.js 看起来像这样:

"use strict";
exports.__esModule = true;
var formselector_mock_1 = require("./dist/page/formselector/formselector.mock");
exports.FormSelectorMock = formselector_mock_1.FormSelectorMock;
var formitem_mock_1 = require("./dist/page/formitem/formitem.mock");
exports.FormItemMock = formitem_mock_1.FormItemMock;
   ... 80 more lines...

我得到每个要求的 404:"http://localhost:62576/test/dist/page/formselector/formselector.mock.js" 应该是 "http://localhost:62576/node_modules/xrm-mock/dist/page/formselector/formselector.mock.js"

我想我可以将每个模块文件添加为带有路径的模块,但我必须定义 40 个模块。有没有更简单的方法?

现在大多数开发者都使用npm插件,你知道吗?消除了对这种手动(和困难的)配置的需要 不过,要回答您的问题,我认为您想要做的是删除 xrm-mock 路径,而是使用

之类的东西
"xrm-mock/*": "../node_modules/xrm-mock/*.js"

然后是主模块的地图:

"map": {
  "xrm-mock": "xrm-mock/index"
}