Skip to content

Commit

Permalink
Merge pull request #151 from rocjs/fix/change-resolver-opt-out
Browse files Browse the repository at this point in the history
Changes the opt-out character from _ to #
  • Loading branch information
andreasrs committed Nov 22, 2016
2 parents 2eae13c + 67934aa commit 2b9b285
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions docs/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,16 @@ Roc will push a lot of the code that you would normally get from a generator awa

With that said you could definitely use Yeoman together with Roc if you so wish.

### An extension is providing me with a dependency, I would like to you the local one in my project. How can I do this?
### An extension is providing me with a dependency, I would like to use the local one in my project. How can I do this?
There currently are two ways to disable exported dependencies from extensions.

1. An easy way is to add a prefix, `_`, in front of the import to disable it from being managed by Roc.
1. An easy way is to add a prefix, `#`, in front of the import to disable it from being managed by Roc.

__Example__
```javascript
import lodash from '_lodash';
import lodash from '#lodash';

var lodash = require('_lodash');
var lodash = require('#lodash');
```

2. If a more permanent solution is desired it is possible to remove a dependecy all together through [the `init` function in `roc.config.js`](/docs/Configuration.md#init).
Expand Down
4 changes: 2 additions & 2 deletions docs/Runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ It is possible to override the provided version if needed. Most of the time this
```javascript
// Will use the react that has been installed in
// the projects package.json and not the exported
import React from '_react';
var React = require('_react');
import React from '#react';
var React = require('#react');
```

#### Uses
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function verifyInstalledProjectDependencies({ dependencies, devDe
`You have some dependencies in your package.json that also have been exported by extensions. This is probably a mistake.
${underline('Roc will prioritize the ones exported by the extensions.')}
You can override this by adding "_" to the start of the require/import in the code, see documentation for more info.
You can override this by adding "#" to the start of the require/import in the code, see documentation for more info.
Dependencies that is both exported and in the projects package.json:
${matches.map((match) => `- ${bold(match.name)} ${dim('from')} ` +
Expand Down
2 changes: 1 addition & 1 deletion src/require/resolveRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function resolveRequest(exports, directory, dependencyContext) {
}

// Provides a way to opt-out of the Roc require system
if (request.charAt(0) === '_') {
if (request.charAt(0) === '#') {
return request.substring(1);
}

Expand Down
2 changes: 1 addition & 1 deletion test/require/resolveRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('roc', () => {
const resolver = resolveRequest(exports, __dirname, dependencyContext)('Test');

it('should bail out of opt-out character is used', () => {
expect(resolver('_a', __dirname))
expect(resolver('#a', __dirname))
.toEqual('a');
});

Expand Down

0 comments on commit 2b9b285

Please sign in to comment.