@ardatan/relay-compiler 12.1.0 → 12.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/relay-compiler +6 -30
- package/codegen/CodegenRunner.js.flow +3 -6
- package/codegen/RelayFileWriter.js.flow +2 -3
- package/core/ASTCache.js.flow +4 -5
- package/core/CompilerContext.js.flow +3 -5
- package/lib/codegen/CodegenRunner.js +1 -5
- package/lib/codegen/RelayFileWriter.js +0 -3
- package/lib/core/ASTCache.js +2 -5
- package/lib/core/CompilerContext.js +1 -5
- package/lib/transforms/SkipRedundantNodesTransform.js +2 -4
- package/package.json +1 -2
- package/transforms/SkipRedundantNodesTransform.js.flow +3 -4
package/bin/relay-compiler
CHANGED
|
@@ -1177,12 +1177,6 @@ module.exports = require("fs");
|
|
|
1177
1177
|
|
|
1178
1178
|
module.exports = require("crypto");
|
|
1179
1179
|
|
|
1180
|
-
/***/ }),
|
|
1181
|
-
/* 15 */
|
|
1182
|
-
/***/ (function(module, exports) {
|
|
1183
|
-
|
|
1184
|
-
module.exports = require("immutable");
|
|
1185
|
-
|
|
1186
1180
|
/***/ }),
|
|
1187
1181
|
/* 16 */
|
|
1188
1182
|
/***/ (function(module, exports, __webpack_require__) {
|
|
@@ -1978,10 +1972,6 @@ var invariant = __webpack_require__(6);
|
|
|
1978
1972
|
var _require = __webpack_require__(1),
|
|
1979
1973
|
createUserError = _require.createUserError; // $FlowFixMe[untyped-import] - immutable.js is not flow-typed
|
|
1980
1974
|
|
|
1981
|
-
|
|
1982
|
-
var _require2 = __webpack_require__(15),
|
|
1983
|
-
ImmutableOrderedMap = _require2.OrderedMap;
|
|
1984
|
-
|
|
1985
1975
|
/**
|
|
1986
1976
|
* An immutable representation of a corpus of documents being compiled together.
|
|
1987
1977
|
* For each document, the context stores the IR and any validation errors.
|
|
@@ -1990,7 +1980,7 @@ var CompilerContext = /*#__PURE__*/function () {
|
|
|
1990
1980
|
// $FlowFixMe[value-as-type]
|
|
1991
1981
|
function CompilerContext(schema) {
|
|
1992
1982
|
this._isMutable = false;
|
|
1993
|
-
this._documents = new
|
|
1983
|
+
this._documents = new Map();
|
|
1994
1984
|
this._withTransform = new WeakMap();
|
|
1995
1985
|
this._schema = schema;
|
|
1996
1986
|
}
|
|
@@ -2106,7 +2096,6 @@ var CompilerContext = /*#__PURE__*/function () {
|
|
|
2106
2096
|
mutableCopy._isMutable = true;
|
|
2107
2097
|
var result = fn(mutableCopy);
|
|
2108
2098
|
result._isMutable = false;
|
|
2109
|
-
result._documents = result._documents.asImmutable();
|
|
2110
2099
|
return this._documents === result._documents ? this : result;
|
|
2111
2100
|
};
|
|
2112
2101
|
|
|
@@ -2521,10 +2510,6 @@ module.exports = CodegenDirectory;
|
|
|
2521
2510
|
|
|
2522
2511
|
var Profiler = __webpack_require__(7); // $FlowFixMe[untyped-import] : Immutable is not typed
|
|
2523
2512
|
|
|
2524
|
-
|
|
2525
|
-
var _require = __webpack_require__(15),
|
|
2526
|
-
ImmutableMap = _require.Map;
|
|
2527
|
-
|
|
2528
2513
|
var ASTCache = /*#__PURE__*/function () {
|
|
2529
2514
|
function ASTCache(config) {
|
|
2530
2515
|
this._documents = new Map();
|
|
@@ -2537,14 +2522,14 @@ var ASTCache = /*#__PURE__*/function () {
|
|
|
2537
2522
|
var _proto = ASTCache.prototype;
|
|
2538
2523
|
|
|
2539
2524
|
_proto.documents = function documents() {
|
|
2540
|
-
return
|
|
2525
|
+
return new Map(this._documents);
|
|
2541
2526
|
} // parse should return the set of changes
|
|
2542
2527
|
;
|
|
2543
2528
|
|
|
2544
2529
|
_proto.parseFiles = function parseFiles(files) {
|
|
2545
2530
|
var _this = this;
|
|
2546
2531
|
|
|
2547
|
-
var documents =
|
|
2532
|
+
var documents = new Map();
|
|
2548
2533
|
files.forEach(function (file) {
|
|
2549
2534
|
if (!file.exists) {
|
|
2550
2535
|
_this._documents["delete"](file.relPath);
|
|
@@ -8530,10 +8515,6 @@ var _require = __webpack_require__(59),
|
|
|
8530
8515
|
/* $FlowFixMe[untyped-import] - importing immutable, which is untyped (and flow
|
|
8531
8516
|
* is sad about it) */
|
|
8532
8517
|
|
|
8533
|
-
|
|
8534
|
-
var _require2 = __webpack_require__(15),
|
|
8535
|
-
ImmutableMap = _require2.Map;
|
|
8536
|
-
|
|
8537
8518
|
var CodegenRunner = /*#__PURE__*/function () {
|
|
8538
8519
|
// parser => writers that are affected by it
|
|
8539
8520
|
function CodegenRunner(options) {
|
|
@@ -8750,7 +8731,7 @@ var CodegenRunner = /*#__PURE__*/function () {
|
|
|
8750
8731
|
_parser2 = _this5$writerConfigs$.parser,
|
|
8751
8732
|
baseParsers = _this5$writerConfigs$.baseParsers,
|
|
8752
8733
|
isGeneratedFile = _this5$writerConfigs$.isGeneratedFile;
|
|
8753
|
-
var baseDocuments =
|
|
8734
|
+
var baseDocuments = new Map();
|
|
8754
8735
|
|
|
8755
8736
|
if (baseParsers) {
|
|
8756
8737
|
baseParsers.forEach(function (baseParserName) {
|
|
@@ -11279,9 +11260,6 @@ var _require = __webpack_require__(76),
|
|
|
11279
11260
|
var _require2 = __webpack_require__(10),
|
|
11280
11261
|
isExecutableDefinitionAST = _require2.isExecutableDefinitionAST;
|
|
11281
11262
|
|
|
11282
|
-
var _require3 = __webpack_require__(15),
|
|
11283
|
-
ImmutableMap = _require3.Map;
|
|
11284
|
-
|
|
11285
11263
|
function compileAll(_ref) {
|
|
11286
11264
|
var baseDir = _ref.baseDir,
|
|
11287
11265
|
baseDocuments = _ref.baseDocuments,
|
|
@@ -17414,8 +17392,6 @@ var _toConsumableArray2 = _interopRequireDefault(__webpack_require__(5));
|
|
|
17414
17392
|
|
|
17415
17393
|
var IRTransformer = __webpack_require__(3);
|
|
17416
17394
|
|
|
17417
|
-
var IMap = __webpack_require__(15).Map;
|
|
17418
|
-
|
|
17419
17395
|
var partitionArray = __webpack_require__(16);
|
|
17420
17396
|
|
|
17421
17397
|
var getIdentifierForSelection = __webpack_require__(41);
|
|
@@ -17527,7 +17503,7 @@ function visitNode(node) {
|
|
|
17527
17503
|
cache = new Map(); // $FlowFixMe[incompatible-use]
|
|
17528
17504
|
|
|
17529
17505
|
var context = this.getContext();
|
|
17530
|
-
return transformNode(context.getSchema(), node, new
|
|
17506
|
+
return transformNode(context.getSchema(), node, new Map()).node;
|
|
17531
17507
|
}
|
|
17532
17508
|
/**
|
|
17533
17509
|
* The most straightforward approach would be two passes: one to record the
|
|
@@ -17583,7 +17559,7 @@ function transformNode(schema, node, selectionMap) {
|
|
|
17583
17559
|
case 'InlineDataFragmentSpread':
|
|
17584
17560
|
case 'LinkedField':
|
|
17585
17561
|
{
|
|
17586
|
-
var transformed = transformNode(schema, selection, selectionMap.get(identifier) || new
|
|
17562
|
+
var transformed = transformNode(schema, selection, selectionMap.get(identifier) || new Map());
|
|
17587
17563
|
|
|
17588
17564
|
if (transformed.node) {
|
|
17589
17565
|
selections.push(transformed.node);
|
|
@@ -21,9 +21,6 @@ const invariant = require('invariant');
|
|
|
21
21
|
const path = require('path');
|
|
22
22
|
|
|
23
23
|
const {create: createSchema} = require('../core/Schema');
|
|
24
|
-
/* $FlowFixMe[untyped-import] - importing immutable, which is untyped (and flow
|
|
25
|
-
* is sad about it) */
|
|
26
|
-
const {Map: ImmutableMap} = require('immutable');
|
|
27
24
|
|
|
28
25
|
import type ASTCache from '../core/ASTCache';
|
|
29
26
|
import type {Schema} from '../core/Schema';
|
|
@@ -62,8 +59,8 @@ type WriterConfigs = {[writer: string]: WriterConfig, ...};
|
|
|
62
59
|
export type WriteFilesOptions = {|
|
|
63
60
|
onlyValidate: boolean,
|
|
64
61
|
schema: Schema,
|
|
65
|
-
documents:
|
|
66
|
-
baseDocuments:
|
|
62
|
+
documents: Map<string, DocumentNode>,
|
|
63
|
+
baseDocuments: Map<string, DocumentNode>,
|
|
67
64
|
sourceControl: ?SourceControl,
|
|
68
65
|
reporter: Reporter,
|
|
69
66
|
generatedDirectories?: Array<string>,
|
|
@@ -273,7 +270,7 @@ class CodegenRunner {
|
|
|
273
270
|
isGeneratedFile,
|
|
274
271
|
} = this.writerConfigs[writerName];
|
|
275
272
|
|
|
276
|
-
let baseDocuments =
|
|
273
|
+
let baseDocuments = new Map();
|
|
277
274
|
if (baseParsers) {
|
|
278
275
|
baseParsers.forEach(baseParserName => {
|
|
279
276
|
invariant(
|
|
@@ -30,7 +30,6 @@ const {
|
|
|
30
30
|
getReaderSourceDefinitionName,
|
|
31
31
|
} = require('../core/GraphQLDerivedFromMetadata');
|
|
32
32
|
const {isExecutableDefinitionAST} = require('../core/SchemaUtils');
|
|
33
|
-
const {Map: ImmutableMap} = require('immutable');
|
|
34
33
|
|
|
35
34
|
import type {Schema} from '../core/Schema';
|
|
36
35
|
import type {
|
|
@@ -147,9 +146,9 @@ function writeAll({
|
|
|
147
146
|
config: WriterConfig,
|
|
148
147
|
onlyValidate: boolean,
|
|
149
148
|
// $FlowFixMe[value-as-type]
|
|
150
|
-
baseDocuments:
|
|
149
|
+
baseDocuments: Map<string, DocumentNode>,
|
|
151
150
|
// $FlowFixMe[value-as-type]
|
|
152
|
-
documents:
|
|
151
|
+
documents: Map<string, DocumentNode>,
|
|
153
152
|
schema: Schema,
|
|
154
153
|
reporter: Reporter,
|
|
155
154
|
sourceControl: ?SourceControl,
|
package/core/ASTCache.js.flow
CHANGED
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
const Profiler = require('./GraphQLCompilerProfiler');
|
|
16
16
|
|
|
17
17
|
// $FlowFixMe[untyped-import] : Immutable is not typed
|
|
18
|
-
const {Map: ImmutableMap} = require('immutable');
|
|
19
18
|
|
|
20
19
|
import type {File} from '../codegen/CodegenTypes';
|
|
21
20
|
import type {DocumentNode} from 'graphql';
|
|
@@ -36,13 +35,13 @@ class ASTCache {
|
|
|
36
35
|
|
|
37
36
|
// Short-term: we don't do subscriptions/delta updates, instead always use all definitions
|
|
38
37
|
// $FlowFixMe[value-as-type]
|
|
39
|
-
documents():
|
|
40
|
-
return
|
|
38
|
+
documents(): Map<string, DocumentNode> {
|
|
39
|
+
return Map(this._documents);
|
|
41
40
|
}
|
|
42
41
|
|
|
43
42
|
// parse should return the set of changes
|
|
44
|
-
parseFiles(files: Set<File>):
|
|
45
|
-
let documents =
|
|
43
|
+
parseFiles(files: Set<File>): Map<string, DocumentNode> {
|
|
44
|
+
let documents = new Map();
|
|
46
45
|
|
|
47
46
|
files.forEach(file => {
|
|
48
47
|
if (!file.exists) {
|
|
@@ -17,8 +17,6 @@ const Profiler = require('./GraphQLCompilerProfiler');
|
|
|
17
17
|
const invariant = require('invariant');
|
|
18
18
|
|
|
19
19
|
const {createUserError} = require('./CompilerError');
|
|
20
|
-
// $FlowFixMe[untyped-import] - immutable.js is not flow-typed
|
|
21
|
-
const {OrderedMap: ImmutableOrderedMap} = require('immutable');
|
|
22
20
|
|
|
23
21
|
import type {Reporter} from '../reporters/Reporter';
|
|
24
22
|
import type {Fragment, Location, Root, SplitOperation} from './IR';
|
|
@@ -35,13 +33,13 @@ export type CompilerContextDocument = Fragment | Root | SplitOperation;
|
|
|
35
33
|
class CompilerContext {
|
|
36
34
|
_isMutable: boolean;
|
|
37
35
|
// $FlowFixMe[value-as-type]
|
|
38
|
-
_documents:
|
|
36
|
+
_documents: Map<string, CompilerContextDocument>;
|
|
39
37
|
_withTransform: WeakMap<IRTransform, CompilerContext>;
|
|
40
38
|
+_schema: Schema;
|
|
41
39
|
|
|
42
40
|
constructor(schema: Schema) {
|
|
43
41
|
this._isMutable = false;
|
|
44
|
-
this._documents = new
|
|
42
|
+
this._documents = new Map();
|
|
45
43
|
this._withTransform = new WeakMap();
|
|
46
44
|
this._schema = schema;
|
|
47
45
|
}
|
|
@@ -174,7 +172,7 @@ class CompilerContext {
|
|
|
174
172
|
}
|
|
175
173
|
|
|
176
174
|
_update(
|
|
177
|
-
documents:
|
|
175
|
+
documents: Map<string, CompilerContextDocument>,
|
|
178
176
|
): CompilerContext {
|
|
179
177
|
const context = this._isMutable
|
|
180
178
|
? this
|
|
@@ -35,10 +35,6 @@ var _require = require('../core/Schema'),
|
|
|
35
35
|
/* $FlowFixMe[untyped-import] - importing immutable, which is untyped (and flow
|
|
36
36
|
* is sad about it) */
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
var _require2 = require('immutable'),
|
|
40
|
-
ImmutableMap = _require2.Map;
|
|
41
|
-
|
|
42
38
|
var CodegenRunner = /*#__PURE__*/function () {
|
|
43
39
|
// parser => writers that are affected by it
|
|
44
40
|
function CodegenRunner(options) {
|
|
@@ -255,7 +251,7 @@ var CodegenRunner = /*#__PURE__*/function () {
|
|
|
255
251
|
_parser2 = _this5$writerConfigs$.parser,
|
|
256
252
|
baseParsers = _this5$writerConfigs$.baseParsers,
|
|
257
253
|
isGeneratedFile = _this5$writerConfigs$.isGeneratedFile;
|
|
258
|
-
var baseDocuments =
|
|
254
|
+
var baseDocuments = new Map();
|
|
259
255
|
|
|
260
256
|
if (baseParsers) {
|
|
261
257
|
baseParsers.forEach(function (baseParserName) {
|
|
@@ -48,9 +48,6 @@ var _require = require('../core/GraphQLDerivedFromMetadata'),
|
|
|
48
48
|
var _require2 = require('../core/SchemaUtils'),
|
|
49
49
|
isExecutableDefinitionAST = _require2.isExecutableDefinitionAST;
|
|
50
50
|
|
|
51
|
-
var _require3 = require('immutable'),
|
|
52
|
-
ImmutableMap = _require3.Map;
|
|
53
|
-
|
|
54
51
|
function compileAll(_ref) {
|
|
55
52
|
var baseDir = _ref.baseDir,
|
|
56
53
|
baseDocuments = _ref.baseDocuments,
|
package/lib/core/ASTCache.js
CHANGED
|
@@ -13,9 +13,6 @@
|
|
|
13
13
|
var Profiler = require('./GraphQLCompilerProfiler'); // $FlowFixMe[untyped-import] : Immutable is not typed
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var _require = require('immutable'),
|
|
17
|
-
ImmutableMap = _require.Map;
|
|
18
|
-
|
|
19
16
|
var ASTCache = /*#__PURE__*/function () {
|
|
20
17
|
function ASTCache(config) {
|
|
21
18
|
this._documents = new Map();
|
|
@@ -28,14 +25,14 @@ var ASTCache = /*#__PURE__*/function () {
|
|
|
28
25
|
var _proto = ASTCache.prototype;
|
|
29
26
|
|
|
30
27
|
_proto.documents = function documents() {
|
|
31
|
-
return
|
|
28
|
+
return Map(this._documents);
|
|
32
29
|
} // parse should return the set of changes
|
|
33
30
|
;
|
|
34
31
|
|
|
35
32
|
_proto.parseFiles = function parseFiles(files) {
|
|
36
33
|
var _this = this;
|
|
37
34
|
|
|
38
|
-
var documents =
|
|
35
|
+
var documents = new Map();
|
|
39
36
|
files.forEach(function (file) {
|
|
40
37
|
if (!file.exists) {
|
|
41
38
|
_this._documents["delete"](file.relPath);
|
|
@@ -17,10 +17,6 @@ var invariant = require('invariant');
|
|
|
17
17
|
var _require = require('./CompilerError'),
|
|
18
18
|
createUserError = _require.createUserError; // $FlowFixMe[untyped-import] - immutable.js is not flow-typed
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
var _require2 = require('immutable'),
|
|
22
|
-
ImmutableOrderedMap = _require2.OrderedMap;
|
|
23
|
-
|
|
24
20
|
/**
|
|
25
21
|
* An immutable representation of a corpus of documents being compiled together.
|
|
26
22
|
* For each document, the context stores the IR and any validation errors.
|
|
@@ -29,7 +25,7 @@ var CompilerContext = /*#__PURE__*/function () {
|
|
|
29
25
|
// $FlowFixMe[value-as-type]
|
|
30
26
|
function CompilerContext(schema) {
|
|
31
27
|
this._isMutable = false;
|
|
32
|
-
this._documents = new
|
|
28
|
+
this._documents = new Map();
|
|
33
29
|
this._withTransform = new WeakMap();
|
|
34
30
|
this._schema = schema;
|
|
35
31
|
}
|
|
@@ -18,8 +18,6 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
|
|
|
18
18
|
|
|
19
19
|
var IRTransformer = require('../core/IRTransformer');
|
|
20
20
|
|
|
21
|
-
var IMap = require('immutable').Map;
|
|
22
|
-
|
|
23
21
|
var partitionArray = require('../util/partitionArray');
|
|
24
22
|
|
|
25
23
|
var getIdentifierForSelection = require('../core/getIdentifierForSelection');
|
|
@@ -131,7 +129,7 @@ function visitNode(node) {
|
|
|
131
129
|
cache = new Map(); // $FlowFixMe[incompatible-use]
|
|
132
130
|
|
|
133
131
|
var context = this.getContext();
|
|
134
|
-
return transformNode(context.getSchema(), node, new
|
|
132
|
+
return transformNode(context.getSchema(), node, new Map()).node;
|
|
135
133
|
}
|
|
136
134
|
/**
|
|
137
135
|
* The most straightforward approach would be two passes: one to record the
|
|
@@ -187,7 +185,7 @@ function transformNode(schema, node, selectionMap) {
|
|
|
187
185
|
case 'InlineDataFragmentSpread':
|
|
188
186
|
case 'LinkedField':
|
|
189
187
|
{
|
|
190
|
-
var transformed = transformNode(schema, selection, selectionMap.get(identifier) || new
|
|
188
|
+
var transformed = transformNode(schema, selection, selectionMap.get(identifier) || new Map());
|
|
191
189
|
|
|
192
190
|
if (transformed.node) {
|
|
193
191
|
selections.push(transformed.node);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ardatan/relay-compiler",
|
|
3
3
|
"description": "A compiler tool for building GraphQL-driven applications.",
|
|
4
|
-
"version": "12.1.
|
|
4
|
+
"version": "12.1.1",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"graphql",
|
|
7
7
|
"relay"
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
"@babel/runtime": "^7.26.10",
|
|
24
24
|
"chalk": "^4.0.0",
|
|
25
25
|
"fb-watchman": "^2.0.0",
|
|
26
|
-
"immutable": "~4.3.8",
|
|
27
26
|
"invariant": "^2.2.4",
|
|
28
27
|
"nullthrows": "^1.1.1",
|
|
29
28
|
"relay-runtime": "12.0.0",
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
const IRTransformer = require('../core/IRTransformer');
|
|
16
16
|
|
|
17
17
|
import type CompilerContext from '../core/CompilerContext';
|
|
18
|
-
const IMap = require('immutable').Map;
|
|
19
18
|
const partitionArray = require('../util/partitionArray');
|
|
20
19
|
const getIdentifierForSelection = require('../core/getIdentifierForSelection');
|
|
21
20
|
const invariant = require('invariant');
|
|
@@ -31,7 +30,7 @@ import type {Fragment, Node, Root, SplitOperation, Selection} from '../core/IR';
|
|
|
31
30
|
* etc).
|
|
32
31
|
*/
|
|
33
32
|
// $FlowFixMe[value-as-type]
|
|
34
|
-
type SelectionMap =
|
|
33
|
+
type SelectionMap = Map<string, ?SelectionMap>;
|
|
35
34
|
|
|
36
35
|
/**
|
|
37
36
|
* A transform that removes redundant fields and fragment spreads. Redundancy is
|
|
@@ -139,7 +138,7 @@ function visitNode<T: Fragment | Root | SplitOperation>(node: T): ?T {
|
|
|
139
138
|
cache = new Map();
|
|
140
139
|
// $FlowFixMe[incompatible-use]
|
|
141
140
|
const context: CompilerContext = this.getContext();
|
|
142
|
-
return transformNode(context.getSchema(), node, new
|
|
141
|
+
return transformNode(context.getSchema(), node, new Map()).node;
|
|
143
142
|
}
|
|
144
143
|
|
|
145
144
|
/**
|
|
@@ -197,7 +196,7 @@ function transformNode<T: Node>(
|
|
|
197
196
|
const transformed = transformNode(
|
|
198
197
|
schema,
|
|
199
198
|
selection,
|
|
200
|
-
selectionMap.get(identifier) || new
|
|
199
|
+
selectionMap.get(identifier) || new Map(),
|
|
201
200
|
);
|
|
202
201
|
if (transformed.node) {
|
|
203
202
|
selections.push(transformed.node);
|