mirror of
https://github.com/status-im/metro.git
synced 2025-02-12 11:07:42 +00:00
Replace @provides with @providesModule
Reviewed By: davidaurelio Differential Revision: D4494624 fbshipit-source-id: 192cc77126a99b3a3baeb806ed605c2194c4713a
This commit is contained in:
parent
09797f281b
commit
310c5d4163
@ -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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -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
|
||||||
*/
|
*/
|
||||||
|
@ -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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -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};
|
||||||
}
|
}
|
||||||
|
@ -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);');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user