gpt4 book ai didi

jspm - 安装 JSPM 插件时如何避免向 config.js 添加依赖项?

转载 作者:行者123 更新时间:2023-12-04 07:52:58 25 4
gpt4 key购买 nike

当我安装 css插件,使用以下命令:

jspm install css

以下添加到我的 config.js 中:
System.config({
"map": {
"css": "github:systemjs/plugin-css@0.1.6",
"github:jspm/nodelibs-assert@0.1.0": {
"assert": "npm:assert@1.3.0"
},
"github:jspm/nodelibs-buffer@0.1.0": {
"buffer": "npm:buffer@3.0.3"
},
"github:jspm/nodelibs-events@0.1.0": {
"events-browserify": "npm:events-browserify@0.0.1"
},
"github:jspm/nodelibs-http@1.7.0": {
"Base64": "npm:Base64@0.2.1",
"events": "github:jspm/nodelibs-events@0.1.0",
"inherits": "npm:inherits@2.0.1",
"stream": "github:jspm/nodelibs-stream@0.1.0",
"url": "github:jspm/nodelibs-url@0.1.0",
"util": "github:jspm/nodelibs-util@0.1.0"
},
"github:jspm/nodelibs-https@0.1.0": {
"https-browserify": "npm:https-browserify@0.0.0"
},
"github:jspm/nodelibs-os@0.1.0": {
"os-browserify": "npm:os-browserify@0.1.2"
},
"github:jspm/nodelibs-path@0.1.0": {
"path-browserify": "npm:path-browserify@0.0.0"
},
"github:jspm/nodelibs-process@0.1.1": {
"process": "npm:process@0.10.1"
},
"github:jspm/nodelibs-stream@0.1.0": {
"stream-browserify": "npm:stream-browserify@1.0.0"
},
"github:jspm/nodelibs-url@0.1.0": {
"url": "npm:url@0.10.3"
},
"github:jspm/nodelibs-util@0.1.0": {
"util": "npm:util@0.10.3"
},
"github:systemjs/plugin-css@0.1.6": {
"clean-css": "npm:clean-css@3.0.10",
"fs": "github:jspm/nodelibs-fs@0.1.1",
"path": "github:jspm/nodelibs-path@0.1.0"
},
"npm:amdefine@0.1.0": {
"fs": "github:jspm/nodelibs-fs@0.1.1",
"module": "github:jspm/nodelibs-module@0.1.0",
"path": "github:jspm/nodelibs-path@0.1.0",
"process": "github:jspm/nodelibs-process@0.1.1"
},
"npm:assert@1.3.0": {
"util": "npm:util@0.10.3"
},
"npm:buffer@3.0.3": {
"base64-js": "npm:base64-js@0.0.8",
"ieee754": "npm:ieee754@1.1.4",
"is-array": "npm:is-array@1.0.1"
},
"npm:clean-css@3.0.10": {
"buffer": "github:jspm/nodelibs-buffer@0.1.0",
"commander": "npm:commander@2.5.1",
"fs": "github:jspm/nodelibs-fs@0.1.1",
"http": "github:jspm/nodelibs-http@1.7.0",
"https": "github:jspm/nodelibs-https@0.1.0",
"os": "github:jspm/nodelibs-os@0.1.0",
"path": "github:jspm/nodelibs-path@0.1.0",
"process": "github:jspm/nodelibs-process@0.1.1",
"source-map": "npm:source-map@0.1.43",
"url": "github:jspm/nodelibs-url@0.1.0",
"util": "github:jspm/nodelibs-util@0.1.0"
},
"npm:commander@2.5.1": {
"child_process": "github:jspm/nodelibs-child_process@0.1.0",
"events": "github:jspm/nodelibs-events@0.1.0",
"path": "github:jspm/nodelibs-path@0.1.0",
"process": "github:jspm/nodelibs-process@0.1.1"
},
"npm:core-util-is@1.0.1": {
"buffer": "github:jspm/nodelibs-buffer@0.1.0"
},
"npm:events-browserify@0.0.1": {
"process": "github:jspm/nodelibs-process@0.1.1"
},
"npm:https-browserify@0.0.0": {
"http": "github:jspm/nodelibs-http@1.7.0"
},
"npm:inherits@2.0.1": {
"util": "github:jspm/nodelibs-util@0.1.0"
},
"npm:os-browserify@0.1.2": {
"os": "github:jspm/nodelibs-os@0.1.0"
},
"npm:path-browserify@0.0.0": {
"process": "github:jspm/nodelibs-process@0.1.1"
},
"npm:punycode@1.3.2": {
"process": "github:jspm/nodelibs-process@0.1.1"
},
"npm:readable-stream@1.1.13": {
"buffer": "github:jspm/nodelibs-buffer@0.1.0",
"core-util-is": "npm:core-util-is@1.0.1",
"events": "github:jspm/nodelibs-events@0.1.0",
"inherits": "npm:inherits@2.0.1",
"isarray": "npm:isarray@0.0.1",
"process": "github:jspm/nodelibs-process@0.1.1",
"stream": "npm:stream-browserify@1.0.0",
"string_decoder": "npm:string_decoder@0.10.31",
"util": "github:jspm/nodelibs-util@0.1.0"
},
"npm:source-map@0.1.43": {
"amdefine": "npm:amdefine@0.1.0",
"fs": "github:jspm/nodelibs-fs@0.1.1",
"path": "github:jspm/nodelibs-path@0.1.0",
"process": "github:jspm/nodelibs-process@0.1.1"
},
"npm:stream-browserify@1.0.0": {
"events": "github:jspm/nodelibs-events@0.1.0",
"inherits": "npm:inherits@2.0.1",
"readable-stream": "npm:readable-stream@1.1.13"
},
"npm:string_decoder@0.10.31": {
"buffer": "github:jspm/nodelibs-buffer@0.1.0"
},
"npm:url@0.10.3": {
"assert": "github:jspm/nodelibs-assert@0.1.0",
"punycode": "npm:punycode@1.3.2",
"querystring": "npm:querystring@0.2.0",
"util": "github:jspm/nodelibs-util@0.1.0"
},
"npm:util@0.10.3": {
"inherits": "npm:inherits@2.0.1",
"process": "github:jspm/nodelibs-process@0.1.1"
}
}
});

如何保持我的 config.js 整洁以避免在我的所有页面中包含所有这些信息(因为 config.js 需要包含在每个页面中)?

最佳答案

我也是 JSPM 的新手,对大型 config.js 也有类似的 react 。大小,但这里有一些我学到的东西:

1) 我不会将 JSPM 用于您只想在服务器端/开发机器上使用的 Node 模块。你可以继续使用 NPM。我犯了这个错误——认为我应该对所有依赖项使用 JSPM,同时替换 Bower 和 NPM。我安装了gulp通过 JSPM,我的 config.js 突然超过 700 行!

2)我想知道是否可以将其配置为仅记录顶级依赖项 - 就像在 package.json 中一样 - 不是所有依赖项的依赖项......听起来不像。我在 Gitter group 中问过响应是:“尽管它很大,但它可以让你控制你在 npm 中没有的对等依赖项”。 (感谢 Mitranim)。

3) 如果你熟悉 require.js,你可以认为你的 config.js 有点像你的 require.config(...) .它所做的其中一件事是设置您的短名称,您可以使用它来包含您的模块。作为一个以前的 require.js 用户,我接受了我需要在前端包含我的 require.js 配置文件作为入口点,它对于 config.js 也是如此 - 至少对于开发......

4)生产是另一回事。报价 Guy Bedford on the Gitter group :“配置文件不应该包含在将要开发的生产\工作流中”。 "Bundle for production" section 中有更多信息在入门指南中。

5) 我发现一个有用的起点是Jack Franklindemo from Async Brighton .特别值得注意的是:他有一个用于生产的捆绑工作流,它将脚本包含的切换为仅指向缩小的 app.min.js - 见 Makefile .

关于jspm - 安装 JSPM 插件时如何避免向 config.js 添加依赖项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28889066/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com