我创建了一个ember插件,它依赖于gulp派生包来构建,所以在插件中它在package.json中有以下内容。
当主应用程序中包含插件时,由于缺少各种gulp模块,构建失败。插件位于主应用程序的devDependencies部分。
当插件通过npm link
时,插件也会构建到主应用程序中。我的问题是如何处理插件依赖关系,以便主应用程序在没有模块的本地副本的情况下构建?
更新:我认为问题是该软件包在postinstall之后进行了一次gulp构建,它将gulp devDependencies提升为真正的依赖项。这是对的吗?
Addon JSON文件
{
"name": "My Addon",
"version": "0.0.0",
"description": "The default blueprint for ember-cli addons.",
"directories": {
"doc": "doc",
"test": "tests"
},
"scripts": {
"build": "ember build",
"start": "ember server",
"test": "ember try:each",
"postinstall": "gulp build && bower install"
},
"repository": {
"type": "git",
"url": "git://github.com/myaddon.git"
},
"engines": {
"node": ">= 0.12.0"
},
"author": "",
"license": "MIT",
"devDependencies": {
"bootstrap": "^4.0.0-alpha.5",
"broccoli-asset-rev": "^2.4.5",
"broccoli-funnel": "^1.0.9",
"ember-ajax": "^2.4.1",
// more ember modules
"find-root": "^0.1.1",
"font-awesome": "^4.7.0",
"glob": "^4.5.3",
"gulp": "^3.9.1",
"gulp-clean-css": "^2.2.1",
"gulp-concat": "^2.6.0",
"gulp-connect": "^2.2.0",
"gulp-filter": "^3.0.1",
"gulp-git": "^1.4.0",
"gulp-rename": "^1.2.2",
"gulp-sass": "^2.3.2",
"gulp-sourcemaps": "^1.5.2",
"gulp-task-loader": "^1.2.1",
"gulp-template": "^3.0.0",
"gulp-uglify": "^1.2.0",
"gulp-zip": "^3.0.2",
"lazypipe": "^1.0.1",
"loader.js": "^4.0.10",
"run-sequence": "^1.1.2"
},
"keywords": [
"ember-addon"
],
"dependencies": {
"ember-cli-babel": "^5.1.7"
},
"ember-addon": {
"configPath": "tests/dummy/config"
}
}
答案 0 :(得分:1)
构建应用程序(包括插件)需要使用插件的依赖关系,应列在dependencies
部分。包含在另一个包的依赖项中的包的devDependencies
将被忽略。
应用程序中有add packages的其他解决方案。您可以在插件中创建blueprint,每次应用程序使用它构建或安装它时都会调用它。