Replace @provides with @providesModule

Reviewed By: davidaurelio

Differential Revision: D4494624

fbshipit-source-id: 192cc77126a99b3a3baeb806ed605c2194c4713a
This commit is contained in:
Bhuwan Khattar 2017-02-02 08:57:06 -08:00 committed by Facebook Github Bot
parent 09797f281b
commit 310c5d4163
9 changed files with 11 additions and 38 deletions

View File

@ -6,7 +6,7 @@
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @provides Array.es6
* @providesModule Array.es6
* @polyfill
*/

View File

@ -6,7 +6,7 @@
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @provides Array.prototype.es6
* @providesModule Array.prototype.es6
* @polyfill
*/

View File

@ -6,7 +6,7 @@
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @provides Number.es6
* @providesModule Number.es6
* @polyfill
*/

View File

@ -6,7 +6,7 @@
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @provides Object.es7
* @providesModule Object.es7
* @polyfill
*/

View File

@ -6,7 +6,7 @@
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @provides String.prototype.es6
* @providesModule String.prototype.es6
* @polyfill
*/

View File

@ -6,7 +6,7 @@
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @provides console
* @providesModule console
* @polyfill
* @nolint
*/

View File

@ -6,7 +6,7 @@
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @provides Object.es6
* @providesModule Object.es6
* @polyfill
*/

View File

@ -184,10 +184,11 @@ class Module {
// modules, such as react-haste, fbjs-haste, or react-native or with non-dependency,
// project-specific code that is using @providesModule.
const moduleDocBlock = docblock.parseAsObject(docBlock);
const provides = moduleDocBlock.providesModule || moduleDocBlock.provides;
const providesModule = moduleDocBlock.providesModule;
const id = provides && !this._depGraphHelpers.isNodeModulesDir(this.path)
? /^\S+/.exec(provides)[0]
const id =
providesModule && !this._depGraphHelpers.isNodeModulesDir(this.path)
? /^\S+/.exec(providesModule)[0]
: undefined;
return {id, moduleDocBlock};
}

View File

@ -125,34 +125,6 @@ describe('Module', () => {
});
});
describe('@provides annotations', () => {
beforeEach(() => {
mockIndexFile(source.replace(/@providesModule/, '@provides'));
});
it('extracts the module name from the header if it has a @provides annotation', () =>
module.getName().then(name => expect(name).toEqual(moduleId))
);
it('identifies the module as haste module', () =>
module.isHaste().then(isHaste => expect(isHaste).toBe(true))
);
it('does not transform the file in order to access the name', () => {
const transformCode =
jest.genMockFn().mockReturnValue(Promise.resolve());
return createModule({transformCode}).getName()
.then(() => expect(transformCode).not.toBeCalled());
});
it('does not transform the file in order to access the haste status', () => {
const transformCode =
jest.genMockFn().mockReturnValue(Promise.resolve());
return createModule({transformCode}).isHaste()
.then(() => expect(transformCode).not.toBeCalled());
});
});
describe('no annotation', () => {
beforeEach(() => {
mockIndexFile('arbitrary(code);');