@embroider/macros 1.21.0 → 1.21.2

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.
Files changed (80) hide show
  1. package/README.md +24 -0
  2. package/package.json +2 -4
  3. package/src/babel/app-ember-satisfies.d.ts +0 -5
  4. package/src/babel/app-ember-satisfies.js +0 -38
  5. package/src/babel/app-ember-satisfies.js.map +0 -1
  6. package/src/babel/dependency-satisfies.d.ts +0 -5
  7. package/src/babel/dependency-satisfies.js +0 -38
  8. package/src/babel/dependency-satisfies.js.map +0 -1
  9. package/src/babel/each.d.ts +0 -14
  10. package/src/babel/each.js +0 -55
  11. package/src/babel/each.js.map +0 -1
  12. package/src/babel/error.d.ts +0 -3
  13. package/src/babel/error.js +0 -21
  14. package/src/babel/error.js.map +0 -1
  15. package/src/babel/evaluate-json.d.ts +0 -36
  16. package/src/babel/evaluate-json.js +0 -429
  17. package/src/babel/evaluate-json.js.map +0 -1
  18. package/src/babel/fail-build.d.ts +0 -5
  19. package/src/babel/fail-build.js +0 -36
  20. package/src/babel/fail-build.js.map +0 -1
  21. package/src/babel/get-config.d.ts +0 -9
  22. package/src/babel/get-config.js +0 -107
  23. package/src/babel/get-config.js.map +0 -1
  24. package/src/babel/import-sync-pattern.d.ts +0 -22
  25. package/src/babel/import-sync-pattern.js +0 -151
  26. package/src/babel/import-sync-pattern.js.map +0 -1
  27. package/src/babel/macro-condition.d.ts +0 -12
  28. package/src/babel/macro-condition.js +0 -76
  29. package/src/babel/macro-condition.js.map +0 -1
  30. package/src/babel/macros-babel-plugin.d.ts +0 -3
  31. package/src/babel/macros-babel-plugin.js +0 -312
  32. package/src/babel/macros-babel-plugin.js.map +0 -1
  33. package/src/babel/module-exists.d.ts +0 -5
  34. package/src/babel/module-exists.js +0 -30
  35. package/src/babel/module-exists.js.map +0 -1
  36. package/src/babel/state.d.ts +0 -34
  37. package/src/babel/state.js +0 -64
  38. package/src/babel/state.js.map +0 -1
  39. package/src/babel.d.ts +0 -47
  40. package/src/babel.js +0 -36
  41. package/src/babel.js.map +0 -1
  42. package/src/ember-addon-main.d.ts +0 -9
  43. package/src/ember-addon-main.js +0 -112
  44. package/src/ember-addon-main.js.map +0 -1
  45. package/src/glimmer/app-ember-satisfies.d.ts +0 -3
  46. package/src/glimmer/app-ember-satisfies.js +0 -32
  47. package/src/glimmer/app-ember-satisfies.js.map +0 -1
  48. package/src/glimmer/ast-transform.d.ts +0 -133
  49. package/src/glimmer/ast-transform.js +0 -240
  50. package/src/glimmer/ast-transform.js.map +0 -1
  51. package/src/glimmer/dependency-satisfies.d.ts +0 -3
  52. package/src/glimmer/dependency-satisfies.js +0 -37
  53. package/src/glimmer/dependency-satisfies.js.map +0 -1
  54. package/src/glimmer/evaluate.d.ts +0 -7
  55. package/src/glimmer/evaluate.js +0 -16
  56. package/src/glimmer/evaluate.js.map +0 -1
  57. package/src/glimmer/fail-build.d.ts +0 -2
  58. package/src/glimmer/fail-build.js +0 -22
  59. package/src/glimmer/fail-build.js.map +0 -1
  60. package/src/glimmer/get-config.d.ts +0 -5
  61. package/src/glimmer/get-config.js +0 -38
  62. package/src/glimmer/get-config.js.map +0 -1
  63. package/src/glimmer/literal.d.ts +0 -2
  64. package/src/glimmer/literal.js +0 -28
  65. package/src/glimmer/literal.js.map +0 -1
  66. package/src/glimmer/macro-condition.d.ts +0 -7
  67. package/src/glimmer/macro-condition.js +0 -119
  68. package/src/glimmer/macro-condition.js.map +0 -1
  69. package/src/glimmer/macro-maybe-attrs.d.ts +0 -2
  70. package/src/glimmer/macro-maybe-attrs.js +0 -31
  71. package/src/glimmer/macro-maybe-attrs.js.map +0 -1
  72. package/src/index.d.ts +0 -59
  73. package/src/index.js +0 -80
  74. package/src/index.js.map +0 -1
  75. package/src/macros-config.d.ts +0 -52
  76. package/src/macros-config.js +0 -394
  77. package/src/macros-config.js.map +0 -1
  78. package/src/node.d.ts +0 -5
  79. package/src/node.js +0 -21
  80. package/src/node.js.map +0 -1
@@ -1,429 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Evaluator = void 0;
7
- exports.assertNotArray = assertNotArray;
8
- exports.assertArray = assertArray;
9
- exports.buildLiterals = buildLiterals;
10
- const dependency_satisfies_1 = __importDefault(require("./dependency-satisfies"));
11
- const app_ember_satisfies_1 = __importDefault(require("./app-ember-satisfies"));
12
- const module_exists_1 = __importDefault(require("./module-exists"));
13
- const get_config_1 = __importDefault(require("./get-config"));
14
- const assert_never_1 = __importDefault(require("assert-never"));
15
- const binops = {
16
- '||': function (a, b) {
17
- return a || b;
18
- },
19
- '&&': function (a, b) {
20
- return a && b;
21
- },
22
- '|': function (a, b) {
23
- return a | b;
24
- },
25
- '^': function (a, b) {
26
- return a ^ b;
27
- },
28
- '&': function (a, b) {
29
- return a & b;
30
- },
31
- '==': function (a, b) {
32
- // eslint-disable-next-line eqeqeq
33
- return a == b;
34
- },
35
- '!=': function (a, b) {
36
- // eslint-disable-next-line eqeqeq
37
- return a != b;
38
- },
39
- '===': function (a, b) {
40
- return a === b;
41
- },
42
- '!==': function (a, b) {
43
- return a !== b;
44
- },
45
- '<': function (a, b) {
46
- return a < b;
47
- },
48
- '>': function (a, b) {
49
- return a > b;
50
- },
51
- '<=': function (a, b) {
52
- return a <= b;
53
- },
54
- '>=': function (a, b) {
55
- return a >= b;
56
- },
57
- '<<': function (a, b) {
58
- return a << b;
59
- },
60
- '>>': function (a, b) {
61
- return a >> b;
62
- },
63
- '>>>': function (a, b) {
64
- return a >>> b;
65
- },
66
- '+': function (a, b) {
67
- return a + b;
68
- },
69
- '-': function (a, b) {
70
- return a - b;
71
- },
72
- '*': function (a, b) {
73
- return a * b;
74
- },
75
- '/': function (a, b) {
76
- return a / b;
77
- },
78
- '%': function (a, b) {
79
- return a % b;
80
- },
81
- '??': function (a, b) {
82
- if (a === null || a === undefined) {
83
- return b;
84
- }
85
- return a;
86
- },
87
- };
88
- const unops = {
89
- '-': function (a) {
90
- return -a;
91
- },
92
- '+': function (a) {
93
- return +a;
94
- },
95
- '~': function (a) {
96
- return ~a;
97
- },
98
- '!': function (a) {
99
- return !a;
100
- },
101
- void: function () {
102
- return undefined;
103
- },
104
- };
105
- class Evaluator {
106
- constructor(env = {}) {
107
- this.knownPaths = env.knownPaths || new Map();
108
- this.locals = env.locals || {};
109
- this.state = env.state;
110
- }
111
- evaluateMember(path, optionalChain) {
112
- let propertyPath = assertNotArray(path.get('property'));
113
- let property;
114
- if (path.node.computed) {
115
- property = this.evaluate(propertyPath);
116
- }
117
- else {
118
- property = this.evaluateKey(propertyPath);
119
- }
120
- if (property.confident) {
121
- let objectPath = path.get('object');
122
- let object = this.evaluate(objectPath);
123
- if (object.confident) {
124
- let confidentObject = object;
125
- let confidentProperty = property;
126
- return {
127
- confident: true,
128
- get value() {
129
- if (optionalChain) {
130
- return confidentObject.value != null
131
- ? confidentObject.value[confidentProperty.value]
132
- : confidentObject.value;
133
- }
134
- else {
135
- return confidentObject.value[confidentProperty.value];
136
- }
137
- },
138
- hasRuntimeImplementation: confidentObject.hasRuntimeImplementation || confidentProperty.hasRuntimeImplementation,
139
- };
140
- }
141
- }
142
- return { confident: false };
143
- }
144
- evaluateKey(path) {
145
- let first = this.evaluate(path);
146
- if (first.confident) {
147
- return first;
148
- }
149
- if (path.isIdentifier()) {
150
- return { confident: true, value: path.node.name, hasRuntimeImplementation: false };
151
- }
152
- return { confident: false };
153
- }
154
- evaluate(path) {
155
- let known = this.knownPaths.get(path);
156
- if (known) {
157
- return known;
158
- }
159
- let result = this.realEvaluate(path);
160
- return result;
161
- }
162
- realEvaluate(path) {
163
- if (path.isMemberExpression()) {
164
- return this.evaluateMember(path, false);
165
- }
166
- // Here we are glossing over the lack of a real OptionalMemberExpression type
167
- // in our @babel/traverse typings.
168
- if (path.node.type === 'OptionalMemberExpression') {
169
- return this.evaluateMember(path, true);
170
- }
171
- if (path.isStringLiteral()) {
172
- return { confident: true, value: path.node.value, hasRuntimeImplementation: false };
173
- }
174
- if (path.isNumericLiteral()) {
175
- return { confident: true, value: path.node.value, hasRuntimeImplementation: false };
176
- }
177
- if (path.isBooleanLiteral()) {
178
- return { confident: true, value: path.node.value, hasRuntimeImplementation: false };
179
- }
180
- if (path.isNullLiteral()) {
181
- return { confident: true, value: null, hasRuntimeImplementation: false };
182
- }
183
- if (path.isIdentifier() && path.node.name === 'undefined') {
184
- return { confident: true, value: undefined, hasRuntimeImplementation: false };
185
- }
186
- if (path.isObjectExpression()) {
187
- let props = assertArray(path.get('properties')).map(p => {
188
- if (p.isSpreadElement()) {
189
- return [{ confident: false }, { confident: false }];
190
- }
191
- let key = assertNotArray(p.get('key'));
192
- let keyEvalValue = this.evaluateKey(key);
193
- let value = assertNotArray(p.get('value'));
194
- let valueEvalValue = this.evaluate(value);
195
- return [keyEvalValue, valueEvalValue];
196
- });
197
- for (let [k, v] of props) {
198
- if (!k.confident || !v.confident) {
199
- return { confident: false };
200
- }
201
- }
202
- let confidentProps = props;
203
- return {
204
- confident: true,
205
- get value() {
206
- let result = {};
207
- for (let [k, v] of confidentProps) {
208
- result[k.value] = v.value;
209
- }
210
- return result;
211
- },
212
- hasRuntimeImplementation: confidentProps.some(([key, value]) => key.hasRuntimeImplementation || value.hasRuntimeImplementation),
213
- };
214
- }
215
- if (path.isArrayExpression()) {
216
- let elements = path.get('elements').map(element => {
217
- return this.evaluate(element);
218
- });
219
- if (elements.every(element => element.confident)) {
220
- let confidentElements = elements;
221
- return {
222
- confident: true,
223
- get value() {
224
- return confidentElements.map(element => element.value);
225
- },
226
- hasRuntimeImplementation: confidentElements.some(el => el.hasRuntimeImplementation),
227
- };
228
- }
229
- }
230
- if (path.isAssignmentExpression()) {
231
- let leftPath = path.get('left');
232
- if (leftPath.isIdentifier()) {
233
- let rightPath = path.get('right');
234
- let right = this.evaluate(rightPath);
235
- if (right.confident) {
236
- this.locals[leftPath.node.name] = right.value;
237
- return right;
238
- }
239
- }
240
- }
241
- if (path.isCallExpression()) {
242
- let result = this.maybeEvaluateRuntimeConfig(path);
243
- if (result.confident) {
244
- return result;
245
- }
246
- result = this.evaluateMacroCall(path);
247
- if (result.confident) {
248
- return result;
249
- }
250
- }
251
- if (path.isLogicalExpression() || path.isBinaryExpression()) {
252
- let operator = path.node.operator;
253
- if (binops[operator]) {
254
- let leftOperand = this.evaluate(path.get('left'));
255
- if (leftOperand.confident) {
256
- let rightOperand = this.evaluate(path.get('right'));
257
- if (leftOperand.confident && rightOperand.confident) {
258
- let value = binops[operator](leftOperand.value, rightOperand.value);
259
- return {
260
- confident: true,
261
- value,
262
- hasRuntimeImplementation: leftOperand.hasRuntimeImplementation || rightOperand.hasRuntimeImplementation,
263
- };
264
- }
265
- }
266
- }
267
- return { confident: false };
268
- }
269
- if (path.isConditionalExpression()) {
270
- let test = this.evaluate(path.get('test'));
271
- if (test.confident) {
272
- let result = test.value ? this.evaluate(path.get('consequent')) : this.evaluate(path.get('alternate'));
273
- if (result.confident) {
274
- return {
275
- confident: true,
276
- value: result.value,
277
- hasRuntimeImplementation: test.hasRuntimeImplementation || result.hasRuntimeImplementation,
278
- };
279
- }
280
- }
281
- }
282
- if (path.isUnaryExpression()) {
283
- let operator = path.node.operator;
284
- if (unops[operator]) {
285
- let operand = this.evaluate(path.get('argument'));
286
- if (operand.confident) {
287
- let value = unops[operator](operand.value);
288
- return { confident: true, value, hasRuntimeImplementation: operand.hasRuntimeImplementation };
289
- }
290
- }
291
- return { confident: false };
292
- }
293
- if (path.isIdentifier()) {
294
- if (!this.locals.hasOwnProperty(path.node.name)) {
295
- return { confident: false };
296
- }
297
- return { confident: true, value: this.locals[path.node.name], hasRuntimeImplementation: false };
298
- }
299
- if (path.isSequenceExpression()) {
300
- let expressions = path.get('expressions');
301
- let lastExpression = expressions[expressions.length - 1];
302
- if (lastExpression) {
303
- // The value of a sequence expression is only the value of the last
304
- // expression it contains, all the rest are ignored.
305
- return this.evaluate(lastExpression);
306
- }
307
- }
308
- return { confident: false };
309
- }
310
- // This handles the presence of our runtime-mode getConfig functions. We want
311
- // to designate them as { confident: true }, because it's important that we
312
- // give feedback even in runtime-mode if the developer is trying to pass
313
- // non-static arguments somewhere they're not supposed to. But we don't
314
- // actually want to calculate their value here because that has been deferred
315
- // to runtime. That's why we've made `value` lazy. It lets us check the
316
- // confidence without actually forcing the value.
317
- maybeEvaluateRuntimeConfig(path) {
318
- if (!this.state) {
319
- return { confident: false };
320
- }
321
- let callee = path.get('callee');
322
- if (callee.isIdentifier()) {
323
- // Does the identifier refer to our runtime config?
324
- if (callee.referencesImport(this.state.pathToOurAddon('runtime'), 'config')) {
325
- return {
326
- confident: true,
327
- get value() {
328
- throw new Error(`bug in @embroider/macros: didn't expect to need to evaluate this value`);
329
- },
330
- hasRuntimeImplementation: true,
331
- };
332
- }
333
- }
334
- return { confident: false };
335
- }
336
- evaluateMacroCall(path) {
337
- if (!this.state) {
338
- return { confident: false };
339
- }
340
- let callee = path.get('callee');
341
- if (callee.referencesImport('@embroider/macros', 'appEmberSatisfies')) {
342
- return { confident: true, value: (0, app_ember_satisfies_1.default)(path, this.state), hasRuntimeImplementation: false };
343
- }
344
- if (callee.referencesImport('@embroider/macros', 'dependencySatisfies')) {
345
- return { confident: true, value: (0, dependency_satisfies_1.default)(path, this.state), hasRuntimeImplementation: false };
346
- }
347
- if (callee.referencesImport('@embroider/macros', 'moduleExists')) {
348
- return { confident: true, value: (0, module_exists_1.default)(path, this.state), hasRuntimeImplementation: false };
349
- }
350
- if (callee.referencesImport('@embroider/macros', 'getConfig')) {
351
- return { confident: true, value: (0, get_config_1.default)(path, this.state, 'package'), hasRuntimeImplementation: false };
352
- }
353
- if (callee.referencesImport('@embroider/macros', 'getOwnConfig')) {
354
- return { confident: true, value: (0, get_config_1.default)(path, this.state, 'own'), hasRuntimeImplementation: false };
355
- }
356
- if (callee.referencesImport('@embroider/macros', 'getGlobalConfig')) {
357
- // Check for getGlobalConfig().fastboot.isRunning, which is the only pattern in use where config actually needs to have a runtime implementation.
358
- // For compatibility reasons we will continue to support that. All other cases of macro configs are static now.
359
- let maybeFastbootMemberExpression = path.parentPath;
360
- if (maybeFastbootMemberExpression.isMemberExpression() ||
361
- maybeFastbootMemberExpression.isOptionalMemberExpression()) {
362
- let maybeFastbootProperty = maybeFastbootMemberExpression.isMemberExpression()
363
- ? maybeFastbootMemberExpression.get('property')
364
- : maybeFastbootMemberExpression.isOptionalMemberExpression()
365
- ? maybeFastbootMemberExpression.get('property')
366
- : (0, assert_never_1.default)(maybeFastbootMemberExpression);
367
- if (maybeFastbootProperty.isIdentifier() && maybeFastbootProperty.node.name === 'fastboot') {
368
- return {
369
- confident: true,
370
- value: (0, get_config_1.default)(path, this.state, 'getGlobalConfig'),
371
- hasRuntimeImplementation: true,
372
- };
373
- }
374
- }
375
- return {
376
- confident: true,
377
- value: (0, get_config_1.default)(path, this.state, 'getGlobalConfig'),
378
- hasRuntimeImplementation: false,
379
- };
380
- }
381
- if (callee.referencesImport('@embroider/macros', 'isDevelopingApp')) {
382
- return {
383
- confident: true,
384
- value: Boolean(this.state.opts.appPackageRoot &&
385
- this.state.opts.isDevelopingPackageRoots.includes(this.state.opts.appPackageRoot)),
386
- hasRuntimeImplementation: false,
387
- };
388
- }
389
- if (callee.referencesImport('@embroider/macros', 'isDevelopingThisPackage')) {
390
- return {
391
- confident: true,
392
- value: this.state.opts.isDevelopingPackageRoots.includes(this.state.originalOwningPackage().root),
393
- hasRuntimeImplementation: false,
394
- };
395
- }
396
- if (callee.referencesImport('@embroider/macros', 'isTesting')) {
397
- let g = (0, get_config_1.default)(path, this.state, 'getGlobalConfig');
398
- let e = g && g['@embroider/macros'];
399
- let value = Boolean(e && e.isTesting);
400
- return { confident: true, value, hasRuntimeImplementation: true };
401
- }
402
- return { confident: false };
403
- }
404
- }
405
- exports.Evaluator = Evaluator;
406
- // these next two functions are here because the type definitions we're using
407
- // don't seem to know exactly which NodePath properties are arrays and which
408
- // aren't.
409
- function assertNotArray(input) {
410
- if (Array.isArray(input)) {
411
- throw new Error(`bug: not supposed to be an array`);
412
- }
413
- return input;
414
- }
415
- function assertArray(input) {
416
- if (!Array.isArray(input)) {
417
- throw new Error(`bug: supposed to be an array`);
418
- }
419
- return input;
420
- }
421
- function buildLiterals(value, babelContext) {
422
- if (typeof value === 'undefined') {
423
- return babelContext.types.identifier('undefined');
424
- }
425
- let statement = babelContext.parseSync(`a(${JSON.stringify(value)})`, { configFile: false });
426
- let expression = statement.program.body[0].expression;
427
- return expression.arguments[0];
428
- }
429
- //# sourceMappingURL=evaluate-json.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"evaluate-json.js","sourceRoot":"","sources":["evaluate-json.ts"],"names":[],"mappings":";;;;;;AA8cA,wCAKC;AACD,kCAKC;AAED,sCAUC;AAjeD,kFAAyD;AACzD,gFAAsD;AACtD,oEAA2C;AAC3C,8DAAqC;AACrC,gEAAuC;AAIvC,MAAM,MAAM,GAAgC;IAC1C,IAAI,EAAE,UAAU,CAAU,EAAE,CAAU;QACpC,OAAO,CAAC,IAAI,CAAC,CAAC;IAChB,CAAC;IACD,IAAI,EAAE,UAAU,CAAU,EAAE,CAAU;QACpC,OAAO,CAAC,IAAI,CAAC,CAAC;IAChB,CAAC;IACD,GAAG,EAAE,UAAU,CAAM,EAAE,CAAM;QAC3B,OAAO,CAAC,GAAG,CAAC,CAAC;IACf,CAAC;IACD,GAAG,EAAE,UAAU,CAAM,EAAE,CAAM;QAC3B,OAAO,CAAC,GAAG,CAAC,CAAC;IACf,CAAC;IACD,GAAG,EAAE,UAAU,CAAM,EAAE,CAAM;QAC3B,OAAO,CAAC,GAAG,CAAC,CAAC;IACf,CAAC;IACD,IAAI,EAAE,UAAU,CAAU,EAAE,CAAU;QACpC,kCAAkC;QAClC,OAAO,CAAC,IAAI,CAAC,CAAC;IAChB,CAAC;IACD,IAAI,EAAE,UAAU,CAAU,EAAE,CAAU;QACpC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AC,KAAK,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,CAAW,CAAC;IACvG,IAAI,UAAU,GAAI,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAA2B,CAAC,UAA8B,CAAC;IACrG,OAAO,UAAU,CAAC,SAAS,CAAC,CAAC,CAAuB,CAAC;AACvD,CAAC","sourcesContent":["import type { NodePath } from '@babel/traverse';\nimport type * as Babel from '@babel/core';\nimport type { types as t } from '@babel/core';\nimport type State from './state';\nimport dependencySatisfies from './dependency-satisfies';\nimport appEmberSatisfies from './app-ember-satisfies';\nimport moduleExists from './module-exists';\nimport getConfig from './get-config';\nimport assertNever from 'assert-never';\n\ntype OpValue = string | boolean | number;\n\nconst binops: { [operator: string]: any } = {\n '||': function (a: OpValue, b: OpValue) {\n return a || b;\n },\n '&&': function (a: OpValue, b: OpValue) {\n return a && b;\n },\n '|': function (a: any, b: any) {\n return a | b;\n },\n '^': function (a: any, b: any) {\n return a ^ b;\n },\n '&': function (a: any, b: any) {\n return a & b;\n },\n '==': function (a: OpValue, b: OpValue) {\n // eslint-disable-next-line eqeqeq\n return a == b;\n },\n '!=': function (a: OpValue, b: OpValue) {\n // eslint-disable-next-line eqeqeq\n return a != b;\n },\n '===': function (a: OpValue, b: OpValue) {\n return a === b;\n },\n '!==': function (a: OpValue, b: OpValue) {\n return a !== b;\n },\n '<': function (a: OpValue, b: OpValue) {\n return a < b;\n },\n '>': function (a: OpValue, b: OpValue) {\n return a > b;\n },\n '<=': function (a: OpValue, b: OpValue) {\n return a <= b;\n },\n '>=': function (a: OpValue, b: OpValue) {\n return a >= b;\n },\n '<<': function (a: any, b: any) {\n return a << b;\n },\n '>>': function (a: any, b: any) {\n return a >> b;\n },\n '>>>': function (a: any, b: any) {\n return a >>> b;\n },\n '+': function (a: any, b: any) {\n return a + b;\n },\n '-': function (a: any, b: any) {\n return a - b;\n },\n '*': function (a: any, b: any) {\n return a * b;\n },\n '/': function (a: any, b: any) {\n return a / b;\n },\n '%': function (a: any, b: any) {\n return a % b;\n },\n '??': function (a: any, b: any) {\n if (a === null || a === undefined) {\n return b;\n }\n return a;\n },\n};\n\nconst unops: { [operator: string]: any } = {\n '-': function (a: OpValue) {\n return -a;\n },\n '+': function (a: OpValue) {\n return +a;\n },\n '~': function (a: OpValue) {\n return ~a;\n },\n '!': function (a: OpValue) {\n return !a;\n },\n void: function () {\n return undefined;\n },\n};\n\nexport interface ConfidentResult {\n confident: true;\n value: any;\n hasRuntimeImplementation: boolean;\n}\n\nexport interface UnknownResult {\n confident: false;\n}\n\nexport type EvaluateResult = ConfidentResult | UnknownResult;\n\nexport interface EvaluationEnv {\n knownPaths?: Map<NodePath, EvaluateResult>;\n locals?: { [localVar: string]: any };\n state?: State;\n}\n\nexport class Evaluator {\n private knownPaths: Map<NodePath, EvaluateResult>;\n private locals: { [localVar: string]: any };\n private state: State | undefined;\n\n constructor(env: EvaluationEnv = {}) {\n this.knownPaths = env.knownPaths || new Map();\n this.locals = env.locals || {};\n this.state = env.state;\n }\n\n evaluateMember(\n path: NodePath<t.MemberExpression | t.OptionalMemberExpression>,\n optionalChain: boolean\n ): EvaluateResult {\n let propertyPath = assertNotArray(path.get('property'));\n let property: EvaluateResult;\n if (path.node.computed) {\n property = this.evaluate(propertyPath);\n } else {\n property = this.evaluateKey(propertyPath);\n }\n if (property.confident) {\n let objectPath = path.get('object');\n let object = this.evaluate(objectPath);\n if (object.confident) {\n let confidentObject = object;\n let confidentProperty = property;\n return {\n confident: true,\n get value() {\n if (optionalChain) {\n return confidentObject.value != null\n ? confidentObject.value[confidentProperty.value]\n : confidentObject.value;\n } else {\n return confidentObject.value[confidentProperty.value];\n }\n },\n hasRuntimeImplementation:\n confidentObject.hasRuntimeImplementation || confidentProperty.hasRuntimeImplementation,\n };\n }\n }\n return { confident: false };\n }\n\n evaluateKey(path: NodePath): EvaluateResult {\n let first = this.evaluate(path);\n if (first.confident) {\n return first;\n }\n if (path.isIdentifier()) {\n return { confident: true, value: path.node.name, hasRuntimeImplementation: false };\n }\n return { confident: false };\n }\n\n evaluate(path: NodePath): EvaluateResult {\n let known = this.knownPaths.get(path);\n if (known) {\n return known;\n }\n let result = this.realEvaluate(path);\n return result;\n }\n\n private realEvaluate(path: NodePath): EvaluateResult {\n if (path.isMemberExpression()) {\n return this.evaluateMember(path, false);\n }\n\n // Here we are glossing over the lack of a real OptionalMemberExpression type\n // in our @babel/traverse typings.\n if (path.node.type === 'OptionalMemberExpression') {\n return this.evaluateMember(path as NodePath<t.OptionalMemberExpression>, true);\n }\n\n if (path.isStringLiteral()) {\n return { confident: true, value: path.node.value, hasRuntimeImplementation: false };\n }\n\n if (path.isNumericLiteral()) {\n return { confident: true, value: path.node.value, hasRuntimeImplementation: false };\n }\n\n if (path.isBooleanLiteral()) {\n return { confident: true, value: path.node.value, hasRuntimeImplementation: false };\n }\n\n if (path.isNullLiteral()) {\n return { confident: true, value: null, hasRuntimeImplementation: false };\n }\n\n if (path.isIdentifier() && path.node.name === 'undefined') {\n return { confident: true, value: undefined, hasRuntimeImplementation: false };\n }\n\n if (path.isObjectExpression()) {\n let props = assertArray(path.get('properties')).map(p => {\n if (p.isSpreadElement()) {\n return [{ confident: false }, { confident: false }];\n }\n let key = assertNotArray(p.get('key'));\n let keyEvalValue = this.evaluateKey(key);\n let value = assertNotArray(p.get('value'));\n let valueEvalValue = this.evaluate(value);\n return [keyEvalValue, valueEvalValue];\n });\n for (let [k, v] of props) {\n if (!k.confident || !v.confident) {\n return { confident: false };\n }\n }\n let confidentProps = props as ConfidentResult[][];\n return {\n confident: true,\n get value() {\n let result: any = {};\n for (let [k, v] of confidentProps) {\n result[k.value] = v.value;\n }\n return result;\n },\n hasRuntimeImplementation: confidentProps.some(\n ([key, value]) => key.hasRuntimeImplementation || value.hasRuntimeImplementation\n ),\n };\n }\n\n if (path.isArrayExpression()) {\n let elements = path.get('elements').map(element => {\n return this.evaluate(element as NodePath);\n });\n if (elements.every(element => element.confident)) {\n let confidentElements = elements as ConfidentResult[];\n return {\n confident: true,\n get value() {\n return confidentElements.map(element => element.value);\n },\n hasRuntimeImplementation: confidentElements.some(el => el.hasRuntimeImplementation),\n };\n }\n }\n\n if (path.isAssignmentExpression()) {\n let leftPath = path.get('left');\n if (leftPath.isIdentifier()) {\n let rightPath = path.get('right');\n let right = this.evaluate(rightPath);\n if (right.confident) {\n this.locals[leftPath.node.name] = right.value;\n return right;\n }\n }\n }\n\n if (path.isCallExpression()) {\n let result = this.maybeEvaluateRuntimeConfig(path);\n if (result.confident) {\n return result;\n }\n result = this.evaluateMacroCall(path);\n if (result.confident) {\n return result;\n }\n }\n\n if (path.isLogicalExpression() || path.isBinaryExpression()) {\n let operator = path.node.operator as string;\n if (binops[operator]) {\n let leftOperand = this.evaluate(path.get('left') as NodePath<t.Expression>);\n if (leftOperand.confident) {\n let rightOperand = this.evaluate(path.get('right') as NodePath<t.Expression>);\n if (leftOperand.confident && rightOperand.confident) {\n let value = binops[operator](leftOperand.value, rightOperand.value);\n return {\n confident: true,\n value,\n hasRuntimeImplementation: leftOperand.hasRuntimeImplementation || rightOperand.hasRuntimeImplementation,\n };\n }\n }\n }\n return { confident: false };\n }\n\n if (path.isConditionalExpression()) {\n let test = this.evaluate(path.get('test'));\n if (test.confident) {\n let result = test.value ? this.evaluate(path.get('consequent')) : this.evaluate(path.get('alternate'));\n if (result.confident) {\n return {\n confident: true,\n value: result.value,\n hasRuntimeImplementation: test.hasRuntimeImplementation || result.hasRuntimeImplementation,\n };\n }\n }\n }\n\n if (path.isUnaryExpression()) {\n let operator = path.node.operator as string;\n if (unops[operator]) {\n let operand = this.evaluate(path.get('argument') as NodePath<t.Expression>);\n if (operand.confident) {\n let value = unops[operator](operand.value);\n return { confident: true, value, hasRuntimeImplementation: operand.hasRuntimeImplementation };\n }\n }\n return { confident: false };\n }\n\n if (path.isIdentifier()) {\n if (!this.locals.hasOwnProperty(path.node.name)) {\n return { confident: false };\n }\n return { confident: true, value: this.locals[path.node.name], hasRuntimeImplementation: false };\n }\n\n if (path.isSequenceExpression()) {\n let expressions = path.get('expressions');\n let lastExpression = expressions[expressions.length - 1];\n if (lastExpression) {\n // The value of a sequence expression is only the value of the last\n // expression it contains, all the rest are ignored.\n return this.evaluate(lastExpression);\n }\n }\n\n return { confident: false };\n }\n\n // This handles the presence of our runtime-mode getConfig functions. We want\n // to designate them as { confident: true }, because it's important that we\n // give feedback even in runtime-mode if the developer is trying to pass\n // non-static arguments somewhere they're not supposed to. But we don't\n // actually want to calculate their value here because that has been deferred\n // to runtime. That's why we've made `value` lazy. It lets us check the\n // confidence without actually forcing the value.\n private maybeEvaluateRuntimeConfig(path: NodePath<t.CallExpression>): EvaluateResult {\n if (!this.state) {\n return { confident: false };\n }\n let callee = path.get('callee');\n if (callee.isIdentifier()) {\n // Does the identifier refer to our runtime config?\n if (callee.referencesImport(this.state.pathToOurAddon('runtime'), 'config')) {\n return {\n confident: true,\n get value() {\n throw new Error(`bug in @embroider/macros: didn't expect to need to evaluate this value`);\n },\n hasRuntimeImplementation: true,\n };\n }\n }\n return { confident: false };\n }\n\n evaluateMacroCall(path: NodePath<t.CallExpression>): EvaluateResult {\n if (!this.state) {\n return { confident: false };\n }\n let callee = path.get('callee');\n if (callee.referencesImport('@embroider/macros', 'appEmberSatisfies')) {\n return { confident: true, value: appEmberSatisfies(path, this.state), hasRuntimeImplementation: false };\n }\n if (callee.referencesImport('@embroider/macros', 'dependencySatisfies')) {\n return { confident: true, value: dependencySatisfies(path, this.state), hasRuntimeImplementation: false };\n }\n if (callee.referencesImport('@embroider/macros', 'moduleExists')) {\n return { confident: true, value: moduleExists(path, this.state), hasRuntimeImplementation: false };\n }\n if (callee.referencesImport('@embroider/macros', 'getConfig')) {\n return { confident: true, value: getConfig(path, this.state, 'package'), hasRuntimeImplementation: false };\n }\n if (callee.referencesImport('@embroider/macros', 'getOwnConfig')) {\n return { confident: true, value: getConfig(path, this.state, 'own'), hasRuntimeImplementation: false };\n }\n if (callee.referencesImport('@embroider/macros', 'getGlobalConfig')) {\n // Check for getGlobalConfig().fastboot.isRunning, which is the only pattern in use where config actually needs to have a runtime implementation.\n // For compatibility reasons we will continue to support that. All other cases of macro configs are static now.\n let maybeFastbootMemberExpression = path.parentPath;\n if (\n maybeFastbootMemberExpression.isMemberExpression() ||\n maybeFastbootMemberExpression.isOptionalMemberExpression()\n ) {\n let maybeFastbootProperty = maybeFastbootMemberExpression.isMemberExpression()\n ? maybeFastbootMemberExpression.get('property')\n : maybeFastbootMemberExpression.isOptionalMemberExpression()\n ? maybeFastbootMemberExpression.get('property')\n : assertNever(maybeFastbootMemberExpression);\n\n if (maybeFastbootProperty.isIdentifier() && maybeFastbootProperty.node.name === 'fastboot') {\n return {\n confident: true,\n value: getConfig(path, this.state, 'getGlobalConfig'),\n hasRuntimeImplementation: true,\n };\n }\n }\n\n return {\n confident: true,\n value: getConfig(path, this.state, 'getGlobalConfig'),\n hasRuntimeImplementation: false,\n };\n }\n if (callee.referencesImport('@embroider/macros', 'isDevelopingApp')) {\n return {\n confident: true,\n value: Boolean(\n this.state.opts.appPackageRoot &&\n this.state.opts.isDevelopingPackageRoots.includes(this.state.opts.appPackageRoot)\n ),\n hasRuntimeImplementation: false,\n };\n }\n if (callee.referencesImport('@embroider/macros', 'isDevelopingThisPackage')) {\n return {\n confident: true,\n value: this.state.opts.isDevelopingPackageRoots.includes(this.state.originalOwningPackage().root),\n hasRuntimeImplementation: false,\n };\n }\n if (callee.referencesImport('@embroider/macros', 'isTesting')) {\n let g = getConfig(path, this.state, 'getGlobalConfig') as any;\n let e = g && g['@embroider/macros'];\n let value = Boolean(e && e.isTesting);\n return { confident: true, value, hasRuntimeImplementation: true };\n }\n return { confident: false };\n }\n}\n\n// these next two functions are here because the type definitions we're using\n// don't seem to know exactly which NodePath properties are arrays and which\n// aren't.\nexport function assertNotArray<T>(input: T | T[]): T {\n if (Array.isArray(input)) {\n throw new Error(`bug: not supposed to be an array`);\n }\n return input;\n}\nexport function assertArray<T>(input: T | T[]): T[] {\n if (!Array.isArray(input)) {\n throw new Error(`bug: supposed to be an array`);\n }\n return input;\n}\n\nexport function buildLiterals(\n value: unknown | undefined,\n babelContext: typeof Babel\n): t.Identifier | t.ObjectExpression {\n if (typeof value === 'undefined') {\n return babelContext.types.identifier('undefined');\n }\n let statement = babelContext.parseSync(`a(${JSON.stringify(value)})`, { configFile: false }) as t.File;\n let expression = (statement.program.body[0] as t.ExpressionStatement).expression as t.CallExpression;\n return expression.arguments[0] as t.ObjectExpression;\n}\n"]}
@@ -1,5 +0,0 @@
1
- import type { NodePath } from '@babel/traverse';
2
- import type { types as t } from '@babel/core';
3
- import type State from './state';
4
- export default function failBuild(path: NodePath<t.CallExpression>, state: State): void;
5
- //# sourceMappingURL=fail-build.d.ts.map
@@ -1,36 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.default = failBuild;
7
- const evaluate_json_1 = require("./evaluate-json");
8
- const error_1 = __importDefault(require("./error"));
9
- const util_1 = require("util");
10
- function failBuild(path, state) {
11
- let args = path.get('arguments');
12
- if (args.length < 1) {
13
- throw (0, error_1.default)(path, `failBuild needs at least one argument`);
14
- }
15
- let e = new evaluate_json_1.Evaluator({ state });
16
- state.jobs.push(() => {
17
- let argValues = args.map(a => e.evaluate(a));
18
- for (let i = 0; i < argValues.length; i++) {
19
- if (!argValues[i].confident) {
20
- throw (0, error_1.default)(args[i], `the arguments to failBuild must be statically known`);
21
- }
22
- }
23
- let confidentArgValues = argValues;
24
- if (!wasRemoved(path, state)) {
25
- maybeEmitError(path, confidentArgValues);
26
- }
27
- });
28
- }
29
- function maybeEmitError(path, argValues) {
30
- let [message, ...rest] = argValues;
31
- throw (0, error_1.default)(path, (0, util_1.format)(`failBuild: ${message.value}`, ...rest.map(r => r.value)));
32
- }
33
- function wasRemoved(path, state) {
34
- return state.removed.has(path.node) || Boolean(path.findParent(p => state.removed.has(p.node)));
35
- }
36
- //# sourceMappingURL=fail-build.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fail-build.js","sourceRoot":"","sources":["fail-build.ts"],"names":[],"mappings":";;;;;AAQA,4BAqBC;AA3BD,mDAA4C;AAE5C,oDAA4B;AAC5B,+BAA8B;AAG9B,SAAwB,SAAS,CAAC,IAAgC,EAAE,KAAY;IAC9E,IAAI,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACjC,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpB,MAAM,IAAA,eAAK,EAAC,IAAI,EAAE,uCAAuC,CAAC,CAAC;IAC7D,CAAC;IAED,IAAI,CAAC,GAAG,IAAI,yBAAS,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IAEjC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE;QACnB,IAAI,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC1C,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;gBAC5B,MAAM,IAAA,eAAK,EAAC,IAAI,CAAC,CAAC,CAAC,EAAE,qDAAqD,CAAC,CAAC;YAC9E,CAAC;QACH,CAAC;QACD,IAAI,kBAAkB,GAAG,SAA8B,CAAC;QAExD,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC;YAC7B,cAAc,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC;QAC3C,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,cAAc,CAAC,IAAgC,EAAE,SAA2B;IACnF,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,SAAS,CAAC;IACnC,MAAM,IAAA,eAAK,EAAC,IAAI,EAAE,IAAA,aAAM,EAAC,cAAc,OAAO,CAAC,KAAK,EAAE,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACtF,CAAC;AAED,SAAS,UAAU,CAAC,IAAc,EAAE,KAAY;IAC9C,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClG,CAAC","sourcesContent":["import type { NodePath } from '@babel/traverse';\nimport type { ConfidentResult } from './evaluate-json';\nimport { Evaluator } from './evaluate-json';\nimport type { types as t } from '@babel/core';\nimport error from './error';\nimport { format } from 'util';\nimport type State from './state';\n\nexport default function failBuild(path: NodePath<t.CallExpression>, state: State) {\n let args = path.get('arguments');\n if (args.length < 1) {\n throw error(path, `failBuild needs at least one argument`);\n }\n\n let e = new Evaluator({ state });\n\n state.jobs.push(() => {\n let argValues = args.map(a => e.evaluate(a));\n for (let i = 0; i < argValues.length; i++) {\n if (!argValues[i].confident) {\n throw error(args[i], `the arguments to failBuild must be statically known`);\n }\n }\n let confidentArgValues = argValues as ConfidentResult[];\n\n if (!wasRemoved(path, state)) {\n maybeEmitError(path, confidentArgValues);\n }\n });\n}\n\nfunction maybeEmitError(path: NodePath<t.CallExpression>, argValues: { value: any }[]) {\n let [message, ...rest] = argValues;\n throw error(path, format(`failBuild: ${message.value}`, ...rest.map(r => r.value)));\n}\n\nfunction wasRemoved(path: NodePath, state: State) {\n return state.removed.has(path.node) || Boolean(path.findParent(p => state.removed.has(p.node)));\n}\n"]}
@@ -1,9 +0,0 @@
1
- import type { NodePath } from '@babel/traverse';
2
- import type State from './state';
3
- import type * as Babel from '@babel/core';
4
- import type { types as t } from '@babel/core';
5
- export type Mode = 'own' | 'getGlobalConfig' | 'package';
6
- export default function getConfig(path: NodePath<t.CallExpression>, state: State, mode: Mode): unknown;
7
- export declare function insertConfig(path: NodePath<t.CallExpression>, state: State, mode: Mode, context: typeof Babel): void;
8
- export declare function inlineRuntimeConfig(path: NodePath<t.FunctionDeclaration>, state: State, context: typeof Babel): void;
9
- //# sourceMappingURL=get-config.d.ts.map
@@ -1,107 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.default = getConfig;
7
- exports.insertConfig = insertConfig;
8
- exports.inlineRuntimeConfig = inlineRuntimeConfig;
9
- const error_1 = __importDefault(require("./error"));
10
- const evaluate_json_1 = require("./evaluate-json");
11
- const assert_never_1 = __importDefault(require("assert-never"));
12
- function getPackage(path, state, mode) {
13
- let packageName;
14
- if (mode === 'own') {
15
- if (path.node.arguments.length !== 0) {
16
- throw (0, error_1.default)(path, `getOwnConfig takes zero arguments, you passed ${path.node.arguments.length}`);
17
- }
18
- packageName = undefined;
19
- }
20
- else if (mode === 'package') {
21
- if (path.node.arguments.length !== 1) {
22
- throw (0, error_1.default)(path, `getConfig takes exactly one argument, you passed ${path.node.arguments.length}`);
23
- }
24
- let packageNode = path.node.arguments[0];
25
- if (packageNode.type !== 'StringLiteral') {
26
- throw (0, error_1.default)((0, evaluate_json_1.assertArray)(path.get('arguments'))[0], `the argument to getConfig must be a string literal`);
27
- }
28
- packageName = packageNode.value;
29
- }
30
- else {
31
- (0, assert_never_1.default)(mode);
32
- }
33
- return targetPackage(state.originalOwningPackage(), packageName, state.packageCache);
34
- }
35
- // this evaluates to the actual value of the config. It can be used directly by the Evaluator.
36
- function getConfig(path, state, mode) {
37
- let config;
38
- if (mode === 'getGlobalConfig') {
39
- return state.opts.globalConfig;
40
- }
41
- let pkg = getPackage(path, state, mode);
42
- if (pkg) {
43
- config = state.opts.userConfigs[pkg.root];
44
- }
45
- return config;
46
- }
47
- // this is the imperative version that's invoked directly by the babel visitor
48
- // when we encounter getConfig. It's implemented in terms of getConfig so we can
49
- // be sure we have the same semantics.
50
- function insertConfig(path, state, mode, context) {
51
- if (state.opts.mode === 'compile-time') {
52
- let config = getConfig(path, state, mode);
53
- let collapsed = collapse(path, config);
54
- let literalResult = (0, evaluate_json_1.buildLiterals)(collapsed.config, context);
55
- collapsed.path.replaceWith(literalResult);
56
- }
57
- else {
58
- if (mode === 'getGlobalConfig') {
59
- let callee = path.get('callee');
60
- callee.replaceWith(state.importUtil.import(callee, state.pathToOurAddon('runtime'), 'getGlobalConfig'));
61
- }
62
- else {
63
- let pkg = getPackage(path, state, mode);
64
- let pkgRoot;
65
- if (pkg) {
66
- pkgRoot = context.types.stringLiteral(pkg.root);
67
- }
68
- else {
69
- pkgRoot = context.types.identifier('undefined');
70
- }
71
- path.replaceWith(context.types.callExpression(state.importUtil.import(path, state.pathToOurAddon('runtime'), 'config'), [
72
- pkgRoot,
73
- ]));
74
- }
75
- }
76
- }
77
- function targetPackage(us, packageName, packageCache) {
78
- if (!packageName) {
79
- return us;
80
- }
81
- try {
82
- let target = packageCache.resolve(packageName, us);
83
- return packageCache.original(target);
84
- }
85
- catch (err) {
86
- return null;
87
- }
88
- }
89
- function collapse(path, config) {
90
- let evaluator = new evaluate_json_1.Evaluator({
91
- knownPaths: new Map([[path, { confident: true, value: config, hasRuntimeImplementation: false }]]),
92
- });
93
- while (true) {
94
- let parentPath = path.parentPath;
95
- let result = evaluator.evaluate(parentPath);
96
- if (!result.confident || parentPath.isAssignmentExpression()) {
97
- return { path, config: evaluator.evaluate(path).value };
98
- }
99
- path = parentPath;
100
- }
101
- }
102
- function inlineRuntimeConfig(path, state, context) {
103
- path.get('body').node.body = [
104
- context.types.returnStatement((0, evaluate_json_1.buildLiterals)({ packages: state.opts.userConfigs, global: state.opts.globalConfig }, context)),
105
- ];
106
- }
107
- //# sourceMappingURL=get-config.js.map