From d82f2553fb0da40b02ca5515767211105e2eec07 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 --- .../UIExplorer/js/ListViewPagingExample.js | 2 +- packager/src/Resolver/polyfills/Array.es6.js | 2 +- .../Resolver/polyfills/Array.prototype.es6.js | 2 +- packager/src/Resolver/polyfills/Number.es6.js | 2 +- packager/src/Resolver/polyfills/Object.es7.js | 2 +- .../polyfills/String.prototype.es6.js | 2 +- packager/src/Resolver/polyfills/console.js | 2 +- packager/src/Resolver/polyfills/polyfills.js | 2 +- packager/src/node-haste/Module.js | 7 +++-- .../src/node-haste/__tests__/Module-test.js | 28 ------------------- website/jsdocs/jsdocs.js | 6 ++-- 11 files changed, 15 insertions(+), 42 deletions(-) diff --git a/Examples/UIExplorer/js/ListViewPagingExample.js b/Examples/UIExplorer/js/ListViewPagingExample.js index 4a50d7b25e0..58d7359e5b7 100644 --- a/Examples/UIExplorer/js/ListViewPagingExample.js +++ b/Examples/UIExplorer/js/ListViewPagingExample.js @@ -18,7 +18,7 @@ * 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. * - * @provides ListViewPagingExample + * @providesModule ListViewPagingExample * @flow */ 'use strict'; diff --git a/packager/src/Resolver/polyfills/Array.es6.js b/packager/src/Resolver/polyfills/Array.es6.js index 8f9088fabb2..cb62e224e22 100644 --- a/packager/src/Resolver/polyfills/Array.es6.js +++ b/packager/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/packager/src/Resolver/polyfills/Array.prototype.es6.js b/packager/src/Resolver/polyfills/Array.prototype.es6.js index 767eec74eb6..d38d05bafe9 100644 --- a/packager/src/Resolver/polyfills/Array.prototype.es6.js +++ b/packager/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/packager/src/Resolver/polyfills/Number.es6.js b/packager/src/Resolver/polyfills/Number.es6.js index 6f077316d61..6d7fbd07fa7 100644 --- a/packager/src/Resolver/polyfills/Number.es6.js +++ b/packager/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/packager/src/Resolver/polyfills/Object.es7.js b/packager/src/Resolver/polyfills/Object.es7.js index 1516fc205b5..a797d31d751 100644 --- a/packager/src/Resolver/polyfills/Object.es7.js +++ b/packager/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/packager/src/Resolver/polyfills/String.prototype.es6.js b/packager/src/Resolver/polyfills/String.prototype.es6.js index 6bfc421f4e1..fb37b342902 100644 --- a/packager/src/Resolver/polyfills/String.prototype.es6.js +++ b/packager/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/packager/src/Resolver/polyfills/console.js b/packager/src/Resolver/polyfills/console.js index 9e5b7ebb94e..94252974fdd 100644 --- a/packager/src/Resolver/polyfills/console.js +++ b/packager/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/packager/src/Resolver/polyfills/polyfills.js b/packager/src/Resolver/polyfills/polyfills.js index db65671404e..a519f7155e6 100644 --- a/packager/src/Resolver/polyfills/polyfills.js +++ b/packager/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/packager/src/node-haste/Module.js b/packager/src/node-haste/Module.js index ba0e60e38ce..389e3ad3a85 100644 --- a/packager/src/node-haste/Module.js +++ b/packager/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/packager/src/node-haste/__tests__/Module-test.js b/packager/src/node-haste/__tests__/Module-test.js index 37af632f355..ad583bb7695 100644 --- a/packager/src/node-haste/__tests__/Module-test.js +++ b/packager/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);'); diff --git a/website/jsdocs/jsdocs.js b/website/jsdocs/jsdocs.js index c3dc78c0bda..139dacdc854 100644 --- a/website/jsdocs/jsdocs.js +++ b/website/jsdocs/jsdocs.js @@ -112,14 +112,14 @@ function getFileDocBlock(commentsForFile) { inCopyrightBlock = true; } - var hasProvides = !!line.match(/^\s*\*\s+@provides/); + var hasProvidesModule = !!line.match(/^\s*\*\s+@providesModule/); var hasFlow = !!line.match(/^\s*\*\s+@flow/); - if (hasFlow || hasProvides) { + if (hasFlow || hasProvidesModule) { inCopyrightBlock = false; } - return !inCopyrightBlock && !hasFlow && !hasProvides; + return !inCopyrightBlock && !hasFlow && !hasProvidesModule; }); docblock = filteredLines.join('\n'); return true;