module-deps icon indicating copy to clipboard operation
module-deps copied to clipboard

Are module-deps options passed as parameter to the transforms?

Open ericmorand opened this issue 6 years ago • 1 comments

The documentation is unclear about this point:

If the transform is a function, it should take the file name as an argument

Then, the example shows a second parameters named opts:

var through = require('through2');
module.exports = function (file, opts) { return through() };

What is this second parameter? Is it the options passed to module-deps constructor?

ericmorand avatar Nov 27 '19 12:11 ericmorand

It's the row.options property on on the input object: https://github.com/browserify/module-deps#input-objects Typically browserify passes it in from its .transform() method, which more or less does:

function transform(transformPathOrFn, transformOptions) {
  mdeps.write({ transform: transformPathOrFn, options: transformOptions })
}

e; And if you pass in an opts.transform option to the module-deps constructor, you can set options like:

moduleDeps({
  transform: [
     ['transformPath', { options: 'here' }]
  ]
})

agree that docs could be clearer about this!

goto-bus-stop avatar Nov 27 '19 13:11 goto-bus-stop