steal icon indicating copy to clipboard operation
steal copied to clipboard

Follow path overrides for node_modules

Open Bajix opened this issue 9 years ago • 0 comments

The way in which StealJS resolves packages is somewhat atypical, and gets in the way of doing requires that aren't prefixed.

Generally, projects will have their dependencies in an assets/lib/src folder. If this folder is set as the baseURL, then doing something like require('foo') should load ./assets/foo.js unless explicitly mapped elsewhere. If this where in fact an install dependency, then the path would resolve to ./assets/node_modules/foo.js. The trick to making this work properly is then to override the path of node_modules, like such:

System.config({
  baseURL: "assets",
  paths: {
    "node_modules": "../node_modules"  
  }
});

This would also remove the need for the #277, as packages would resolve to the proper paths without any additional syntax.

Bajix avatar Jun 07 '16 19:06 Bajix