These are chat archives for systemjs/systemjs

26th
May 2016
Ben Sandwick
@ben657
May 26 2016 14:08

So using a module that depends on moment, I have

{
  "main": "dist/mdPickers.js",
  "meta": {
    "dist/mdPickers.js": {
      "format": "global",
      "deps": [
        "moment",
        "./mdPickers.css!"
      ],
      "globals": {
        "moment": "moment"
      }
    }
  }
}

as it's .json file, and moment installed as 'moment', but still not getting moment available to the module as a global. Thought I had my head round shimming globals at last but apparently not!

0.17.0-beta.14 of jspm
λex Vincent
@alexisvincent
May 26 2016 19:54
@guybedford Whats the best way to provide an alternative file for an npm import? Im importing caniuse-api which tries to load json files without specifying an extension and id like to replace it. And in another file i want to make a slight modification untill a pull request is accepted
@everyone or if anyone else has a solution?
Guy Bedford
@guybedford
May 26 2016 21:37
@alexisvincent if you install it with jspm install npm:caniuse-api or whatever it is, have a look at jspm_packages/npm/caniuse-api@x.y.z.json to see how jspm does this with package configuration
@ben657 that should definitely work. You can test the meta is applying in the first place by setting the format to something invalid like format: 'register' which should then throw. Then you know your meta is working. If the meta is working and the global isn't being defined, I'm not sure that case is possible though.
λex Vincent
@alexisvincent
May 26 2016 21:38
@guybedford I tried but cant get it to work. I’ve tried mapping the file to an external one. But doesnt resolve
  "overrides":{
    "npm:caniuse-api@1.4.1": {
      map: {
        "./features.js": “/jspm/caniuse/features.js"
      }
    },
@guybedford internally the package does a require(‘../features’) which has a bunch of issues i want to fix. So i want to supply an external file. its just difficult to see how to do this, since caniuse-api maps to lib and feautures sits in the root package.json dir
Guy Bedford
@guybedford
May 26 2016 21:48
@alexisvincent you can do the above fine assuming the file is jspm_packages/npm/caniuse-api@1.4.1/features.js that you want to map.
λex Vincent
@alexisvincent
May 26 2016 21:50
@guybedford it is, is it correct to map to /some/path for the SystemJS base path?
because the above doesnt work
Guy Bedford
@guybedford
May 26 2016 21:56
@alexisvincent if I do jspm install npm:caniuse-api@1.4.1 there is no file at jspm_packages/npm/caniuse-api@1.4.1/features.js
so I'm not sure how that would work
λex Vincent
@alexisvincent
May 26 2016 21:57
@guybedford it requires a build step, you need to go into the package and run node generator.js
it has a postInstall hook that never fires
but even after running the generator, the generator script explicitely removes the .json extension, dont ask me why :/
Nyalab/caniuse-api#36 Nyalab/caniuse-api#42
Guy Bedford
@guybedford
May 26 2016 21:59
ok
you can map to anything
λex Vincent
@alexisvincent
May 26 2016 22:00
@guybedford is override a package.json option or System.config
Guy Bedford
@guybedford
May 26 2016 22:00
a package.json option that then requires reinstalling the package
λex Vincent
@alexisvincent
May 26 2016 22:00
will a simple jspm install worl
Guy Bedford
@guybedford
May 26 2016 22:00
the easiest way to test configs is to directly edit the jspm_packages/npm/caniuse-api@1.4.1.json file
then you don't need to reinstall or anything just refresh
that's the best way to modify existing overrides
λex Vincent
@alexisvincent
May 26 2016 22:01
got it.
Thanks :)
Guy Bedford
@guybedford
May 26 2016 22:03
sure
λex Vincent
@alexisvincent
May 26 2016 22:07
@guybedford When setting overrides in a local package, can i specify the base url?
  "jspm": {
    "overrides": {
      "./features.js": "/jspm/caniuse-api@1.4.1/features.js"
    }
  }
oh wait. Didnt specify map
this still doesnt work
  "jspm": {
    "overrides": {
      "map": {
        "./features.js": "/jspm/caniuse-api@1.4.1/features.js"
      }
    }
  }
@guybedford When setting overrides in a local package, can i specify the base url?
Guy Bedford
@guybedford
May 26 2016 22:29
the local package package@x.y.z.json file is not an override
that is a SystemJS package configuration
overrides and jspm properties are not recognised in it
λex Vincent
@alexisvincent
May 26 2016 22:33
@guybedford got it. Working now. But as a weird side effect the following occurs. caniuse is a dependentcy of another package i use. so i cant override it. Now if i install it and do the above, I explicitely need to install all the modules that the overridden file imports. My intuition tells me this should not be the expected behaviour.
@guybedford Hmm Also, all files the new file references, are taken from the location of the swopped out file.
λex Vincent
@alexisvincent
May 26 2016 22:38
So this doesn’t really work as an swop, Do you have a suppestion of how I might achieve this?
For now im explicitely saying require('css-modules-loader-core/lib/parser’) instead of just require(‘./parser’)