Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ericmorand opened this issue Nov 27, 2019 · 1 comment
Open

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

ericmorand opened this issue Nov 27, 2019 · 1 comment

Comments

@ericmorand
Copy link

ericmorand commented Nov 27, 2019

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?

@goto-bus-stop
Copy link
Member

goto-bus-stop commented Nov 27, 2019

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants