jspm / npm

NPM Location Service
19 stars 34 forks source link

Overriding dependency in "browser" field does not result in overridden dependency. #129

Closed MeoMix closed 8 years ago

MeoMix commented 8 years ago

Ref: https://github.com/jspm/jspm-cli/issues/1611

I put:

  "jspm": {
    "browser": {
      "cssnano": "@empty"
    }
  }

I expect cssnano to resolve to empty in the browser, but instead, I get the following:

    "github:MeoMix/jspm-loader-css@master": {
      "map": {
        "css-modules-loader-core": "npm:css-modules-loader-core@1.0.0",
        "cssnano": "npm:cssnano@3.5.2",
        "node-cssnano": "npm:cssnano@3.5.2"
      }
    }

which still resolves cssnano to the full package.

guybedford commented 8 years ago

Thanks, I've just updated the description to exclude assuming the solution.

tkhyn commented 8 years ago

Hello, I have a similar issue here using @empty, and it seems closely related (if it isn't, LMK and I'll create another). I want to use alasql but don't need the xlsjs and xlsx dependencies anywhere. So I wrote in my package.json:

"jspm": {
  "dependencies": {
    "alasql": "npm:alasql@0.2.5"
  },
  "overrides": {
    "alasql@0.2.5": {
      "map": {
        "xlsjs": "@empty",
        "xlsx": "@empty"
      }
    }
  }
}

However, this seems to be ignored by jspm, as the xls* packages and all their dependencies are downloaded and resolved in jspm.config.js. If I manually uninstall them and then manually edit jspm.config.js to replace references to xlsjs and xlsx by @empty, everything works. But I understand (correct me if I am wrong) one should expect the @empty-ed packages not to be downloaded / resolved / linked at all. Or at least that's what I would expect!

Thanks in advance for looking into this.

guybedford commented 8 years ago

We don't actually skip downloading for empty packages by default. Rather you need to also set the dependencies to object to exclude the dependencies.

tkhyn commented 8 years ago

Ok thanks, I'll keep my comments regarding download for a new issue then, to avoid polluting this one *.

Independently of the fact that the packages are downloaded or not, do you confirm that, in the above case, the "xlsjs" and "xlsx" should be absent from the packages in "jspm.config.js" (and marked as @empty in the alasql package) after jspm install? If not then I haven't understood a thing about overrides and @empty!

* EDIT: Thanks to your reply I've actually found that using jspm.overrides["alasql@0.2.5"].dependencies = {} achieved what I wanted to do. The reason I thought @empty-ed packages should not be downloaded came from #77 and fa4be763c19f. Thanks again, I'm slowly getting to understand how things work in jspm!

guybedford commented 8 years ago

@tkhyn sure, glad to hear that. Yes there are a lot of complexities to handling this "interoperability" layer with existing ecosystems. Hopefully we can get the docs up to a level in due course to explain all these intricacies properly.