【问题标题】:ember/npm addon with dependencies/ devDependencies带有依赖项/ devDependencies 的 ember/npm 插件
【发布时间】:2016-12-16 20:10:28
【问题描述】:

我创建了一个 ember 插件,它依赖于 gulp 派生的包来构建,所以在插件中它在 package.json 中有以下内容。

当插件包含在主应用程序中时,由于缺少各种 gulp 模块,构建失败。该插件位于主应用程序的 devDependencies 部分。

当插件通过npm link 进入时,它也会构建到主应用程序中。我的问题是如何处理插件依赖项,以便在没有模块本地副本的情况下构建主应用程序?

更新:我认为问题在于包在 postinstall 之后进行了 gulp 构建,这将 gulp devDependencies 提升为真正的依赖项。这是正确的吗?

插件 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"
  }
}

【问题讨论】:

    标签: node.js ember.js npm npm-install


    【解决方案1】:

    构建应用程序(包括插件)需要插件的依赖项,应在dependencies 部分列出。一个包的 devDependencies 作为另一个包的依赖项被包含在内,将被忽略。

    还有其他解决方案可以将add packages 放入应用程序。您可以在插件中创建一个blueprint,每次使用它构建或安装应用程序时都会调用它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-15
      • 2018-09-03
      • 2015-01-03
      • 2016-07-13
      • 2020-11-17
      • 2017-03-02
      • 2013-10-20
      • 2018-04-04
      相关资源
      最近更新 更多