From 310c5d4163feb2eb7d725cd7e31d0e8af57edc20 Mon Sep 17 00:00:00 2001 From: Bhuwan Khattar Date: Thu, 2 Feb 2017 08:57:06 -0800 Subject: [PATCH] Replace @provides with @providesModule Reviewed By: davidaurelio Differential Revision: D4494624 fbshipit-source-id: 192cc77126a99b3a3baeb806ed605c2194c4713a --- .../src/Resolver/polyfills/Array.es6.js | 2 +- .../Resolver/polyfills/Array.prototype.es6.js | 2 +- .../src/Resolver/polyfills/Number.es6.js | 2 +- .../src/Resolver/polyfills/Object.es7.js | 2 +- .../polyfills/String.prototype.es6.js | 2 +- .../src/Resolver/polyfills/console.js | 2 +- .../src/Resolver/polyfills/polyfills.js | 2 +- .../metro-bundler/src/node-haste/Module.js | 7 +++-- .../src/node-haste/__tests__/Module-test.js | 28 ------------------- 9 files changed, 11 insertions(+), 38 deletions(-) diff --git a/packages/metro-bundler/src/Resolver/polyfills/Array.es6.js b/packages/metro-bundler/src/Resolver/polyfills/Array.es6.js index 8f9088fa..cb62e224 100644 --- a/packages/metro-bundler/src/Resolver/polyfills/Array.es6.js +++ b/packages/metro-bundler/src/Resolver/polyfills/Array.es6.js @@ -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 */ diff --git a/packages/metro-bundler/src/Resolver/polyfills/Array.prototype.es6.js b/packages/metro-bundler/src/Resolver/polyfills/Array.prototype.es6.js index 767eec74..d38d05ba 100644 --- a/packages/metro-bundler/src/Resolver/polyfills/Array.prototype.es6.js +++ b/packages/metro-bundler/src/Resolver/polyfills/Array.prototype.es6.js @@ -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 */ diff --git a/packages/metro-bundler/src/Resolver/polyfills/Number.es6.js b/packages/metro-bundler/src/Resolver/polyfills/Number.es6.js index 6f077316..6d7fbd07 100644 --- a/packages/metro-bundler/src/Resolver/polyfills/Number.es6.js +++ b/packages/metro-bundler/src/Resolver/polyfills/Number.es6.js @@ -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 */ diff --git a/packages/metro-bundler/src/Resolver/polyfills/Object.es7.js b/packages/metro-bundler/src/Resolver/polyfills/Object.es7.js index 1516fc20..a797d31d 100644 --- a/packages/metro-bundler/src/Resolver/polyfills/Object.es7.js +++ b/packages/metro-bundler/src/Resolver/polyfills/Object.es7.js @@ -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 */ diff --git a/packages/metro-bundler/src/Resolver/polyfills/String.prototype.es6.js b/packages/metro-bundler/src/Resolver/polyfills/String.prototype.es6.js index 6bfc421f..fb37b342 100644 --- a/packages/metro-bundler/src/Resolver/polyfills/String.prototype.es6.js +++ b/packages/metro-bundler/src/Resolver/polyfills/String.prototype.es6.js @@ -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 */ diff --git a/packages/metro-bundler/src/Resolver/polyfills/console.js b/packages/metro-bundler/src/Resolver/polyfills/console.js index 9e5b7ebb..94252974 100644 --- a/packages/metro-bundler/src/Resolver/polyfills/console.js +++ b/packages/metro-bundler/src/Resolver/polyfills/console.js @@ -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 */ diff --git a/packages/metro-bundler/src/Resolver/polyfills/polyfills.js b/packages/metro-bundler/src/Resolver/polyfills/polyfills.js index db656714..a519f715 100644 --- a/packages/metro-bundler/src/Resolver/polyfills/polyfills.js +++ b/packages/metro-bundler/src/Resolver/polyfills/polyfills.js @@ -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 */ diff --git a/packages/metro-bundler/src/node-haste/Module.js b/packages/metro-bundler/src/node-haste/Module.js index ba0e60e3..389e3ad3 100644 --- a/packages/metro-bundler/src/node-haste/Module.js +++ b/packages/metro-bundler/src/node-haste/Module.js @@ -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}; } diff --git a/packages/metro-bundler/src/node-haste/__tests__/Module-test.js b/packages/metro-bundler/src/node-haste/__tests__/Module-test.js index 37af632f..ad583bb7 100644 --- a/packages/metro-bundler/src/node-haste/__tests__/Module-test.js +++ b/packages/metro-bundler/src/node-haste/__tests__/Module-test.js @@ -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);');