@ardatan/relay-compiler 12.1.2 → 12.2.0

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