Skip to content

Commit

Permalink
feat: add resolve option (#24)
Browse files Browse the repository at this point in the history
* add resolve option

* or any array

* make opts.resolve work for non-cwd modules

* value is required
  • Loading branch information
hipstersmoothie authored and egoist committed Mar 23, 2019
1 parent d5677e3 commit d62867a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,13 @@ Default: `undefined`

npm registry to install the package from. By default it uses the default npm registry.

#### resolve

Type: `string` `string[]`<br>
Default: `undefined`

Extra folders to resolve local node_modules from.

## Contributing

1. Fork it!
Expand Down
4 changes: 4 additions & 0 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ cli
.option('--analyze', 'Analyze bundled files')
.option('--port <port>', 'Port to start analyze on. Defaults to 8888')
.option('--registry <registry>', 'npm registry URL to install from')
.option(
'--resolve <directory>',
'Extra folders to resolve local node_modules from'
)
.example(` package-size react,react-dom`)
.example(` package-size styled-jsx/style --externals react`)
.example(` package-size ./dist/my-bundle.js`)
Expand Down
4 changes: 4 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ module.exports = co.wrap(function*(name, opts = {}) {
if (yarnGlobal.inDirectory(__dirname)) {
config.resolve.modules.push(path.join(yarnGlobal.getDirectory()))
}

if (opts.resolve) {
config.resolve.modules = config.resolve.modules.concat(opts.resolve)
}

if (isCwd) {
config.resolve.modules.unshift(path.join(process.cwd(), 'node_modules'))
Expand Down

0 comments on commit d62867a

Please sign in to comment.