mirror of https://github.com/status-im/metro.git
packager: add transform-class-properties transform
Summary: I found myself a few times wanting that transform, that makes it slightly simpler to have bound method. So I propose we add it. Not a big deal though. Note it also allows static properties with the same syntax, that is handy. Reviewed By: davidaurelio Differential Revision: D5051579 fbshipit-source-id: 7ebf7c709bf52a30a525550c1eda1a6a2f7b8e1e
This commit is contained in:
parent
b5b443f2a5
commit
aadd914f0d
|
@ -25,6 +25,7 @@ function config(onlyList) {
|
||||||
'syntax-trailing-function-commas',
|
'syntax-trailing-function-commas',
|
||||||
'transform-object-rest-spread',
|
'transform-object-rest-spread',
|
||||||
'transform-async-to-generator',
|
'transform-async-to-generator',
|
||||||
|
'transform-class-properties',
|
||||||
].map(pluginName => require(`babel-plugin-${pluginName}`)),
|
].map(pluginName => require(`babel-plugin-${pluginName}`)),
|
||||||
only: _only,
|
only: _only,
|
||||||
retainLines: true,
|
retainLines: true,
|
||||||
|
|
|
@ -110,15 +110,15 @@ function tryResolveSync<T>(action: () => T, secondaryAction: () => T): T {
|
||||||
}
|
}
|
||||||
|
|
||||||
class ResolutionRequest<TModule: Moduleish, TPackage: Packageish> {
|
class ResolutionRequest<TModule: Moduleish, TPackage: Packageish> {
|
||||||
_doesFileExist: (filePath: string) => boolean;
|
_doesFileExist = filePath => this._options.hasteFS.exists(filePath);
|
||||||
_immediateResolutionCache: {[key: string]: TModule};
|
_immediateResolutionCache: {[key: string]: TModule};
|
||||||
_options: Options<TModule, TPackage>;
|
_options: Options<TModule, TPackage>;
|
||||||
static emptyModule: string;
|
|
||||||
|
static EMPTY_MODULE: string = require.resolve('./assets/empty-module.js');
|
||||||
|
|
||||||
constructor(options: Options<TModule, TPackage>) {
|
constructor(options: Options<TModule, TPackage>) {
|
||||||
this._options = options;
|
this._options = options;
|
||||||
this._resetResolutionCache();
|
this._resetResolutionCache();
|
||||||
this._doesFileExist = filePath => this._options.hasteFS.exists(filePath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_tryResolve<T>(
|
_tryResolve<T>(
|
||||||
|
@ -465,7 +465,7 @@ class ResolutionRequest<TModule: Moduleish, TPackage: Packageish> {
|
||||||
);
|
);
|
||||||
if (realModuleName === false) {
|
if (realModuleName === false) {
|
||||||
return this._loadAsFile(
|
return this._loadAsFile(
|
||||||
ResolutionRequest.emptyModule,
|
ResolutionRequest.EMPTY_MODULE,
|
||||||
fromModule,
|
fromModule,
|
||||||
toModuleName,
|
toModuleName,
|
||||||
);
|
);
|
||||||
|
@ -485,7 +485,7 @@ class ResolutionRequest<TModule: Moduleish, TPackage: Packageish> {
|
||||||
// exclude
|
// exclude
|
||||||
if (realModuleName === false) {
|
if (realModuleName === false) {
|
||||||
return this._loadAsFile(
|
return this._loadAsFile(
|
||||||
ResolutionRequest.emptyModule,
|
ResolutionRequest.EMPTY_MODULE,
|
||||||
fromModule,
|
fromModule,
|
||||||
toModuleName,
|
toModuleName,
|
||||||
);
|
);
|
||||||
|
@ -814,6 +814,4 @@ function getArrayLowestItem(a: Array<string>): string | void {
|
||||||
return lowest;
|
return lowest;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResolutionRequest.emptyModule = require.resolve('./assets/empty-module.js');
|
|
||||||
|
|
||||||
module.exports = ResolutionRequest;
|
module.exports = ResolutionRequest;
|
||||||
|
|
|
@ -1819,7 +1819,7 @@ describe('DependencyGraph', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support browser exclude of a package ("' + fieldName + '")', function() {
|
it('should support browser exclude of a package ("' + fieldName + '")', function() {
|
||||||
ResolutionRequest.emptyModule = '/root/emptyModule.js';
|
ResolutionRequest.EMPTY_MODULE = '/root/emptyModule.js';
|
||||||
var root = '/root';
|
var root = '/root';
|
||||||
setMockFileSystem({
|
setMockFileSystem({
|
||||||
'root': {
|
'root': {
|
||||||
|
@ -1885,7 +1885,7 @@ describe('DependencyGraph', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support browser exclude of a file ("' + fieldName + '")', function() {
|
it('should support browser exclude of a file ("' + fieldName + '")', function() {
|
||||||
ResolutionRequest.emptyModule = '/root/emptyModule.js';
|
ResolutionRequest.EMPTY_MODULE = '/root/emptyModule.js';
|
||||||
|
|
||||||
var root = '/root';
|
var root = '/root';
|
||||||
setMockFileSystem({
|
setMockFileSystem({
|
||||||
|
|
Loading…
Reference in New Issue