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 0ed31eb3d6
commit d82f2553fb
11 changed files with 15 additions and 42 deletions

View File

@ -18,7 +18,7 @@
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* *
* @provides ListViewPagingExample * @providesModule ListViewPagingExample
* @flow * @flow
*/ */
'use strict'; 'use strict';

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -112,14 +112,14 @@ function getFileDocBlock(commentsForFile) {
inCopyrightBlock = true; inCopyrightBlock = true;
} }
var hasProvides = !!line.match(/^\s*\*\s+@provides/); var hasProvidesModule = !!line.match(/^\s*\*\s+@providesModule/);
var hasFlow = !!line.match(/^\s*\*\s+@flow/); var hasFlow = !!line.match(/^\s*\*\s+@flow/);
if (hasFlow || hasProvides) { if (hasFlow || hasProvidesModule) {
inCopyrightBlock = false; inCopyrightBlock = false;
} }
return !inCopyrightBlock && !hasFlow && !hasProvides; return !inCopyrightBlock && !hasFlow && !hasProvidesModule;
}); });
docblock = filteredLines.join('\n'); docblock = filteredLines.join('\n');
return true; return true;