@rollup/plugin-node-resolve 8.4.0 → 11.0.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/dist/cjs/index.js CHANGED
@@ -2,316 +2,157 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
-
7
5
  var path = require('path');
8
- var builtinList = _interopDefault(require('builtin-modules'));
9
- var deepFreeze = _interopDefault(require('deep-freeze'));
10
- var deepMerge = _interopDefault(require('deepmerge'));
11
- var isModule = _interopDefault(require('is-module'));
6
+ var builtinList = require('builtin-modules');
7
+ var deepMerge = require('deepmerge');
8
+ var isModule = require('is-module');
12
9
  var fs = require('fs');
13
- var fs__default = _interopDefault(fs);
14
10
  var util = require('util');
11
+ var resolve = require('resolve');
15
12
  var pluginutils = require('@rollup/pluginutils');
16
- var resolveModule = _interopDefault(require('resolve'));
17
-
18
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
19
- try {
20
- var info = gen[key](arg);
21
- var value = info.value;
22
- } catch (error) {
23
- reject(error);
24
- return;
25
- }
26
-
27
- if (info.done) {
28
- resolve(value);
29
- } else {
30
- Promise.resolve(value).then(_next, _throw);
31
- }
32
- }
33
-
34
- function _asyncToGenerator(fn) {
35
- return function () {
36
- var self = this,
37
- args = arguments;
38
- return new Promise(function (resolve, reject) {
39
- var gen = fn.apply(self, args);
40
-
41
- function _next(value) {
42
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
43
- }
44
-
45
- function _throw(err) {
46
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
47
- }
48
-
49
- _next(undefined);
50
- });
51
- };
52
- }
53
-
54
- function _slicedToArray(arr, i) {
55
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
56
- }
57
-
58
- function _arrayWithHoles(arr) {
59
- if (Array.isArray(arr)) return arr;
60
- }
61
-
62
- function _iterableToArrayLimit(arr, i) {
63
- if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
64
- var _arr = [];
65
- var _n = true;
66
- var _d = false;
67
- var _e = undefined;
68
-
69
- try {
70
- for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
71
- _arr.push(_s.value);
72
-
73
- if (i && _arr.length === i) break;
74
- }
75
- } catch (err) {
76
- _d = true;
77
- _e = err;
78
- } finally {
79
- try {
80
- if (!_n && _i["return"] != null) _i["return"]();
81
- } finally {
82
- if (_d) throw _e;
83
- }
84
- }
85
-
86
- return _arr;
87
- }
88
-
89
- function _unsupportedIterableToArray(o, minLen) {
90
- if (!o) return;
91
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
92
- var n = Object.prototype.toString.call(o).slice(8, -1);
93
- if (n === "Object" && o.constructor) n = o.constructor.name;
94
- if (n === "Map" || n === "Set") return Array.from(n);
95
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
96
- }
97
-
98
- function _arrayLikeToArray(arr, len) {
99
- if (len == null || len > arr.length) len = arr.length;
100
-
101
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
102
-
103
- return arr2;
104
- }
105
-
106
- function _nonIterableRest() {
107
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
108
- }
109
13
 
110
- function _createForOfIteratorHelper(o) {
111
- if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
112
- if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) {
113
- var i = 0;
14
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
114
15
 
115
- var F = function () {};
116
-
117
- return {
118
- s: F,
119
- n: function () {
120
- if (i >= o.length) return {
121
- done: true
122
- };
123
- return {
124
- done: false,
125
- value: o[i++]
126
- };
127
- },
128
- e: function (e) {
129
- throw e;
130
- },
131
- f: F
132
- };
133
- }
16
+ var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
17
+ var builtinList__default = /*#__PURE__*/_interopDefaultLegacy(builtinList);
18
+ var deepMerge__default = /*#__PURE__*/_interopDefaultLegacy(deepMerge);
19
+ var isModule__default = /*#__PURE__*/_interopDefaultLegacy(isModule);
20
+ var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
21
+ var resolve__default = /*#__PURE__*/_interopDefaultLegacy(resolve);
134
22
 
135
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
136
- }
23
+ const exists = util.promisify(fs__default['default'].exists);
24
+ const readFile = util.promisify(fs__default['default'].readFile);
25
+ const realpath = util.promisify(fs__default['default'].realpath);
26
+ const stat = util.promisify(fs__default['default'].stat);
137
27
 
138
- var it,
139
- normalCompletion = true,
140
- didErr = false,
141
- err;
142
- return {
143
- s: function () {
144
- it = o[Symbol.iterator]();
145
- },
146
- n: function () {
147
- var step = it.next();
148
- normalCompletion = step.done;
149
- return step;
150
- },
151
- e: function (e) {
152
- didErr = true;
153
- err = e;
154
- },
155
- f: function () {
156
- try {
157
- if (!normalCompletion && it.return != null) it.return();
158
- } finally {
159
- if (didErr) throw err;
160
- }
161
- }
162
- };
163
- }
164
-
165
- const exists = util.promisify(fs__default.exists);
166
- const readFile = util.promisify(fs__default.readFile);
167
- const realpath = util.promisify(fs__default.realpath);
168
- const stat = util.promisify(fs__default.stat);
169
-
170
- const onError = error => {
28
+ const onError = (error) => {
171
29
  if (error.code === 'ENOENT') {
172
30
  return false;
173
31
  }
174
-
175
32
  throw error;
176
33
  };
177
34
 
178
- const makeCache = fn => {
35
+ const makeCache = (fn) => {
179
36
  const cache = new Map();
180
-
181
- const wrapped = /*#__PURE__*/function () {
182
- var _ref = _asyncToGenerator(function* (param, done) {
183
- if (cache.has(param) === false) {
184
- cache.set(param, fn(param).catch(err => {
37
+ const wrapped = async (param, done) => {
38
+ if (cache.has(param) === false) {
39
+ cache.set(
40
+ param,
41
+ fn(param).catch((err) => {
185
42
  cache.delete(param);
186
43
  throw err;
187
- }));
188
- }
189
-
190
- try {
191
- const result = cache.get(param);
192
- const value = yield result;
193
- return done(null, value);
194
- } catch (error) {
195
- return done(error);
196
- }
197
- });
44
+ })
45
+ );
46
+ }
198
47
 
199
- return function wrapped(_x, _x2) {
200
- return _ref.apply(this, arguments);
201
- };
202
- }();
48
+ try {
49
+ const result = cache.get(param);
50
+ const value = await result;
51
+ return done(null, value);
52
+ } catch (error) {
53
+ return done(error);
54
+ }
55
+ };
203
56
 
204
57
  wrapped.clear = () => cache.clear();
205
58
 
206
59
  return wrapped;
207
60
  };
208
61
 
209
- const isDirCached = makeCache( /*#__PURE__*/function () {
210
- var _ref2 = _asyncToGenerator(function* (file) {
211
- try {
212
- const stats = yield stat(file);
213
- return stats.isDirectory();
214
- } catch (error) {
215
- return onError(error);
216
- }
217
- });
62
+ const isDirCached = makeCache(async (file) => {
63
+ try {
64
+ const stats = await stat(file);
65
+ return stats.isDirectory();
66
+ } catch (error) {
67
+ return onError(error);
68
+ }
69
+ });
218
70
 
219
- return function (_x3) {
220
- return _ref2.apply(this, arguments);
221
- };
222
- }());
223
- const isFileCached = makeCache( /*#__PURE__*/function () {
224
- var _ref3 = _asyncToGenerator(function* (file) {
225
- try {
226
- const stats = yield stat(file);
227
- return stats.isFile();
228
- } catch (error) {
229
- return onError(error);
230
- }
231
- });
71
+ const isFileCached = makeCache(async (file) => {
72
+ try {
73
+ const stats = await stat(file);
74
+ return stats.isFile();
75
+ } catch (error) {
76
+ return onError(error);
77
+ }
78
+ });
232
79
 
233
- return function (_x4) {
234
- return _ref3.apply(this, arguments);
235
- };
236
- }());
237
80
  const readCachedFile = makeCache(readFile);
238
81
 
239
- const resolveId = util.promisify(resolveModule); // returns the imported package name for bare module imports
240
-
82
+ // returns the imported package name for bare module imports
241
83
  function getPackageName(id) {
242
84
  if (id.startsWith('.') || id.startsWith('/')) {
243
85
  return null;
244
86
  }
245
87
 
246
- const split = id.split('/'); // @my-scope/my-package/foo.js -> @my-scope/my-package
247
- // @my-scope/my-package -> @my-scope/my-package
88
+ const split = id.split('/');
248
89
 
90
+ // @my-scope/my-package/foo.js -> @my-scope/my-package
91
+ // @my-scope/my-package -> @my-scope/my-package
249
92
  if (split[0][0] === '@') {
250
93
  return `${split[0]}/${split[1]}`;
251
- } // my-package/foo.js -> my-package
252
- // my-package -> my-package
253
-
94
+ }
254
95
 
96
+ // my-package/foo.js -> my-package
97
+ // my-package -> my-package
255
98
  return split[0];
256
99
  }
100
+
257
101
  function getMainFields(options) {
258
102
  let mainFields;
259
-
260
103
  if (options.mainFields) {
261
- mainFields = options.mainFields;
104
+ ({ mainFields } = options);
262
105
  } else {
263
106
  mainFields = ['module', 'main'];
264
107
  }
265
-
266
108
  if (options.browser && mainFields.indexOf('browser') === -1) {
267
109
  return ['browser'].concat(mainFields);
268
110
  }
269
-
270
111
  if (!mainFields.length) {
271
112
  throw new Error('Please ensure at least one `mainFields` value is specified');
272
113
  }
273
-
274
114
  return mainFields;
275
115
  }
116
+
276
117
  function getPackageInfo(options) {
277
- const cache = options.cache,
278
- extensions = options.extensions,
279
- pkg = options.pkg,
280
- mainFields = options.mainFields,
281
- preserveSymlinks = options.preserveSymlinks,
282
- useBrowserOverrides = options.useBrowserOverrides;
283
- let pkgPath = options.pkgPath;
118
+ const { cache, extensions, pkg, mainFields, preserveSymlinks, useBrowserOverrides } = options;
119
+ let { pkgPath } = options;
284
120
 
285
121
  if (cache.has(pkgPath)) {
286
122
  return cache.get(pkgPath);
287
- } // browserify/resolve doesn't realpath paths returned in its packageFilter callback
288
-
123
+ }
289
124
 
125
+ // browserify/resolve doesn't realpath paths returned in its packageFilter callback
290
126
  if (!preserveSymlinks) {
291
127
  pkgPath = fs.realpathSync(pkgPath);
292
128
  }
293
129
 
294
130
  const pkgRoot = path.dirname(pkgPath);
131
+
295
132
  const packageInfo = {
296
133
  // copy as we are about to munge the `main` field of `pkg`.
297
- packageJson: Object.assign({}, pkg),
134
+ packageJson: { ...pkg },
135
+
298
136
  // path to package.json file
299
137
  packageJsonPath: pkgPath,
138
+
300
139
  // directory containing the package.json
301
140
  root: pkgRoot,
141
+
302
142
  // which main field was used during resolution of this module (main, module, or browser)
303
143
  resolvedMainField: 'main',
144
+
304
145
  // whether the browser map was used to resolve the entry point to this module
305
146
  browserMappedMain: false,
147
+
306
148
  // the entry point of the module with respect to the selected main field and any
307
149
  // relevant browser mappings.
308
150
  resolvedEntryPoint: ''
309
151
  };
310
- let overriddenMain = false;
311
152
 
153
+ let overriddenMain = false;
312
154
  for (let i = 0; i < mainFields.length; i++) {
313
155
  const field = mainFields[i];
314
-
315
156
  if (typeof pkg[field] === 'string') {
316
157
  pkg.main = pkg[field];
317
158
  packageInfo.resolvedMainField = field;
@@ -324,37 +165,38 @@ function getPackageInfo(options) {
324
165
  cachedPkg: pkg,
325
166
  hasModuleSideEffects: () => null,
326
167
  hasPackageEntry: overriddenMain !== false || mainFields.indexOf('main') !== -1,
327
- packageBrowserField: useBrowserOverrides && typeof pkg.browser === 'object' && Object.keys(pkg.browser).reduce((browser, key) => {
328
- let resolved = pkg.browser[key];
329
-
330
- if (resolved && resolved[0] === '.') {
331
- resolved = path.resolve(pkgRoot, resolved);
332
- }
333
- /* eslint-disable no-param-reassign */
334
-
335
-
336
- browser[key] = resolved;
337
-
338
- if (key[0] === '.') {
339
- const absoluteKey = path.resolve(pkgRoot, key);
340
- browser[absoluteKey] = resolved;
341
-
342
- if (!path.extname(key)) {
343
- extensions.reduce((subBrowser, ext) => {
344
- subBrowser[absoluteKey + ext] = subBrowser[key];
345
- return subBrowser;
346
- }, browser);
168
+ packageBrowserField:
169
+ useBrowserOverrides &&
170
+ typeof pkg.browser === 'object' &&
171
+ Object.keys(pkg.browser).reduce((browser, key) => {
172
+ let resolved = pkg.browser[key];
173
+ if (resolved && resolved[0] === '.') {
174
+ resolved = path.resolve(pkgRoot, resolved);
347
175
  }
348
- }
349
-
350
- return browser;
351
- }, {}),
176
+ /* eslint-disable no-param-reassign */
177
+ browser[key] = resolved;
178
+ if (key[0] === '.') {
179
+ const absoluteKey = path.resolve(pkgRoot, key);
180
+ browser[absoluteKey] = resolved;
181
+ if (!path.extname(key)) {
182
+ extensions.reduce((subBrowser, ext) => {
183
+ subBrowser[absoluteKey + ext] = subBrowser[key];
184
+ return subBrowser;
185
+ }, browser);
186
+ }
187
+ }
188
+ return browser;
189
+ }, {}),
352
190
  packageInfo
353
191
  };
354
- const browserMap = internalPackageInfo.packageBrowserField;
355
192
 
356
- if (useBrowserOverrides && typeof pkg.browser === 'object' && // eslint-disable-next-line no-prototype-builtins
357
- browserMap.hasOwnProperty(pkg.main)) {
193
+ const browserMap = internalPackageInfo.packageBrowserField;
194
+ if (
195
+ useBrowserOverrides &&
196
+ typeof pkg.browser === 'object' &&
197
+ // eslint-disable-next-line no-prototype-builtins
198
+ browserMap.hasOwnProperty(pkg.main)
199
+ ) {
358
200
  packageInfo.resolvedEntryPoint = browserMap[pkg.main];
359
201
  packageInfo.browserMappedMain = true;
360
202
  } else {
@@ -364,7 +206,6 @@ function getPackageInfo(options) {
364
206
  }
365
207
 
366
208
  const packageSideEffects = pkg.sideEffects;
367
-
368
209
  if (typeof packageSideEffects === 'boolean') {
369
210
  internalPackageInfo.hasModuleSideEffects = () => packageSideEffects;
370
211
  } else if (Array.isArray(packageSideEffects)) {
@@ -376,70 +217,403 @@ function getPackageInfo(options) {
376
217
  cache.set(pkgPath, internalPackageInfo);
377
218
  return internalPackageInfo;
378
219
  }
220
+
379
221
  function normalizeInput(input) {
380
222
  if (Array.isArray(input)) {
381
223
  return input;
382
224
  } else if (typeof input === 'object') {
383
225
  return Object.values(input);
384
- } // otherwise it's a string
385
-
226
+ }
386
227
 
228
+ // otherwise it's a string
387
229
  return [input];
388
- } // Resolve module specifiers in order. Promise resolves to the first module that resolves
389
- // successfully, or the error that resulted from the last attempted module resolution.
230
+ }
390
231
 
391
- function resolveImportSpecifiers(importSpecifierList, resolveOptions) {
392
- let promise = Promise.resolve();
232
+ const resolveImportPath = util.promisify(resolve__default['default']);
233
+ const readFile$1 = util.promisify(fs__default['default'].readFile);
393
234
 
394
- for (let i = 0; i < importSpecifierList.length; i++) {
395
- promise = promise.then(value => {
396
- // if we've already resolved to something, just return it.
397
- if (value) {
398
- return value;
235
+ const pathNotFoundError = (importPath, importer, subPath, pkgPath) =>
236
+ new Error(
237
+ `Could not resolve import "${importPath}" in "${importer}".` +
238
+ ` Package subpath "${subPath}" is not defined by "exports" in ${pkgPath}`
239
+ );
240
+
241
+ function findExportKeyMatch(exportMap, subPath) {
242
+ if (subPath in exportMap) {
243
+ return subPath;
244
+ }
245
+
246
+ const matchKeys = Object.keys(exportMap)
247
+ .filter((key) => key.endsWith('/') || key.endsWith('*'))
248
+ .sort((a, b) => b.length - a.length);
249
+
250
+ for (const key of matchKeys) {
251
+ if (key.endsWith('*')) {
252
+ // star match: "./foo/*": "./foo/*.js"
253
+ const keyWithoutStar = key.substring(0, key.length - 1);
254
+ if (subPath.startsWith(keyWithoutStar)) {
255
+ return key;
399
256
  }
257
+ }
400
258
 
401
- return resolveId(importSpecifierList[i], resolveOptions).then(result => {
402
- if (!resolveOptions.preserveSymlinks) {
403
- result = fs.realpathSync(result);
404
- }
259
+ if (key.endsWith('/') && subPath.startsWith(key)) {
260
+ // directory match (deprecated by node): "./foo/": "./foo/.js"
261
+ return key;
262
+ }
263
+
264
+ if (key === subPath) {
265
+ // literal match
266
+ return key;
267
+ }
268
+ }
269
+ return null;
270
+ }
271
+
272
+ function mapSubPath({ importPath, importer, pkgJsonPath, subPath, key, value }) {
273
+ if (typeof value === 'string') {
274
+ if (typeof key === 'string' && key.endsWith('*')) {
275
+ // star match: "./foo/*": "./foo/*.js"
276
+ const keyWithoutStar = key.substring(0, key.length - 1);
277
+ const subPathAfterKey = subPath.substring(keyWithoutStar.length);
278
+ return value.replace(/\*/g, subPathAfterKey);
279
+ }
280
+
281
+ if (value.endsWith('/')) {
282
+ // directory match (deprecated by node): "./foo/": "./foo/.js"
283
+ return `${value}${subPath.substring(key.length)}`;
284
+ }
285
+
286
+ // mapping is a string, for example { "./foo": "./dist/foo.js" }
287
+ return value;
288
+ }
405
289
 
406
- return result;
290
+ if (Array.isArray(value)) {
291
+ // mapping is an array with fallbacks, for example { "./foo": ["foo:bar", "./dist/foo.js"] }
292
+ return value.find((v) => v.startsWith('./'));
293
+ }
294
+
295
+ throw pathNotFoundError(importPath, importer, subPath, pkgJsonPath);
296
+ }
297
+
298
+ function findEntrypoint({
299
+ importPath,
300
+ importer,
301
+ pkgJsonPath,
302
+ subPath,
303
+ exportMap,
304
+ conditions,
305
+ key
306
+ }) {
307
+ if (typeof exportMap !== 'object') {
308
+ return mapSubPath({ importPath, importer, pkgJsonPath, subPath, key, value: exportMap });
309
+ }
310
+
311
+ // iterate conditions recursively, find the first that matches all conditions
312
+ for (const [condition, subExportMap] of Object.entries(exportMap)) {
313
+ if (conditions.includes(condition)) {
314
+ const mappedSubPath = findEntrypoint({
315
+ importPath,
316
+ importer,
317
+ pkgJsonPath,
318
+ subPath,
319
+ exportMap: subExportMap,
320
+ conditions,
321
+ key
407
322
  });
323
+ if (mappedSubPath) {
324
+ return mappedSubPath;
325
+ }
326
+ }
327
+ }
328
+ throw pathNotFoundError(importer, subPath, pkgJsonPath);
329
+ }
330
+
331
+ function findEntrypointTopLevel({
332
+ importPath,
333
+ importer,
334
+ pkgJsonPath,
335
+ subPath,
336
+ exportMap,
337
+ conditions
338
+ }) {
339
+ if (typeof exportMap !== 'object') {
340
+ // the export map shorthand, for example { exports: "./index.js" }
341
+ if (subPath !== '.') {
342
+ // shorthand only supports a main entrypoint
343
+ throw pathNotFoundError(importPath, importer, subPath, pkgJsonPath);
344
+ }
345
+ return mapSubPath({ importPath, importer, pkgJsonPath, subPath, key: null, value: exportMap });
346
+ }
347
+
348
+ // export map is an object, the top level can be either conditions or sub path mappings
349
+ const keys = Object.keys(exportMap);
350
+ const isConditions = keys.every((k) => !k.startsWith('.'));
351
+ const isMappings = keys.every((k) => k.startsWith('.'));
352
+
353
+ if (!isConditions && !isMappings) {
354
+ throw new Error(
355
+ `Invalid package config ${pkgJsonPath}, "exports" cannot contain some keys starting with '.'` +
356
+ ' and some not. The exports object must either be an object of package subpath keys or an object of main entry' +
357
+ ' condition name keys only.'
358
+ );
359
+ }
360
+
361
+ let key = null;
362
+ let exportMapForSubPath;
363
+
364
+ if (isConditions) {
365
+ // top level is conditions, for example { "import": ..., "require": ..., "module": ... }
366
+ if (subPath !== '.') {
367
+ // package with top level conditions means it only supports a main entrypoint
368
+ throw pathNotFoundError(importPath, importer, subPath, pkgJsonPath);
369
+ }
370
+ exportMapForSubPath = exportMap;
371
+ } else {
372
+ // top level is sub path mappings, for example { ".": ..., "./foo": ..., "./bar": ... }
373
+ key = findExportKeyMatch(exportMap, subPath);
374
+ if (!key) {
375
+ throw pathNotFoundError(importPath, importer, subPath, pkgJsonPath);
376
+ }
377
+ exportMapForSubPath = exportMap[key];
378
+ }
379
+
380
+ return findEntrypoint({
381
+ importPath,
382
+ importer,
383
+ pkgJsonPath,
384
+ subPath,
385
+ exportMap: exportMapForSubPath,
386
+ conditions,
387
+ key
388
+ });
389
+ }
390
+
391
+ async function resolveId({
392
+ importer,
393
+ importPath,
394
+ exportConditions,
395
+ warn,
396
+ packageInfoCache,
397
+ extensions,
398
+ mainFields,
399
+ preserveSymlinks,
400
+ useBrowserOverrides,
401
+ baseDir,
402
+ moduleDirectories
403
+ }) {
404
+ let hasModuleSideEffects = () => null;
405
+ let hasPackageEntry = true;
406
+ let packageBrowserField = false;
407
+ let packageInfo;
408
+
409
+ const filter = (pkg, pkgPath) => {
410
+ const info = getPackageInfo({
411
+ cache: packageInfoCache,
412
+ extensions,
413
+ pkg,
414
+ pkgPath,
415
+ mainFields,
416
+ preserveSymlinks,
417
+ useBrowserOverrides
408
418
  });
409
419
 
410
- if (i < importSpecifierList.length - 1) {
411
- // swallow MODULE_NOT_FOUND errors from all but the last resolution
412
- promise = promise.catch(error => {
413
- if (error.code !== 'MODULE_NOT_FOUND') {
414
- throw error;
415
- }
416
- });
420
+ ({ packageInfo, hasModuleSideEffects, hasPackageEntry, packageBrowserField } = info);
421
+
422
+ return info.cachedPkg;
423
+ };
424
+
425
+ const resolveOptions = {
426
+ basedir: baseDir,
427
+ readFile: readCachedFile,
428
+ isFile: isFileCached,
429
+ isDirectory: isDirCached,
430
+ extensions,
431
+ includeCoreModules: false,
432
+ moduleDirectory: moduleDirectories,
433
+ preserveSymlinks,
434
+ packageFilter: filter
435
+ };
436
+
437
+ let location;
438
+
439
+ const pkgName = getPackageName(importPath);
440
+ if (pkgName) {
441
+ let pkgJsonPath;
442
+ let pkgJson;
443
+ try {
444
+ pkgJsonPath = await resolveImportPath(`${pkgName}/package.json`, resolveOptions);
445
+ pkgJson = JSON.parse(await readFile$1(pkgJsonPath, 'utf-8'));
446
+ } catch (_) {
447
+ // if there is no package.json we defer to regular resolve behavior
417
448
  }
449
+
450
+ if (pkgJsonPath && pkgJson && pkgJson.exports) {
451
+ try {
452
+ const packageSubPath =
453
+ pkgName === importPath ? '.' : `.${importPath.substring(pkgName.length)}`;
454
+ const mappedSubPath = findEntrypointTopLevel({
455
+ importer,
456
+ importPath,
457
+ pkgJsonPath,
458
+ subPath: packageSubPath,
459
+ exportMap: pkgJson.exports,
460
+ conditions: exportConditions
461
+ });
462
+ const pkgDir = path__default['default'].dirname(pkgJsonPath);
463
+ location = path__default['default'].join(pkgDir, mappedSubPath);
464
+ } catch (error) {
465
+ warn(error);
466
+ return null;
467
+ }
468
+ }
469
+ }
470
+
471
+ if (!location) {
472
+ try {
473
+ location = await resolveImportPath(importPath, resolveOptions);
474
+ } catch (error) {
475
+ if (error.code !== 'MODULE_NOT_FOUND') {
476
+ throw error;
477
+ }
478
+ return null;
479
+ }
480
+ }
481
+
482
+ if (!preserveSymlinks) {
483
+ if (await exists(location)) {
484
+ location = await realpath(location);
485
+ }
486
+ }
487
+
488
+ return {
489
+ location,
490
+ hasModuleSideEffects,
491
+ hasPackageEntry,
492
+ packageBrowserField,
493
+ packageInfo
494
+ };
495
+ }
496
+
497
+ // Resolve module specifiers in order. Promise resolves to the first module that resolves
498
+ // successfully, or the error that resulted from the last attempted module resolution.
499
+ async function resolveImportSpecifiers({
500
+ importer,
501
+ importSpecifierList,
502
+ exportConditions,
503
+ warn,
504
+ packageInfoCache,
505
+ extensions,
506
+ mainFields,
507
+ preserveSymlinks,
508
+ useBrowserOverrides,
509
+ baseDir,
510
+ moduleDirectories
511
+ }) {
512
+ for (let i = 0; i < importSpecifierList.length; i++) {
513
+ // eslint-disable-next-line no-await-in-loop
514
+ const resolved = await resolveId({
515
+ importer,
516
+ importPath: importSpecifierList[i],
517
+ exportConditions,
518
+ warn,
519
+ packageInfoCache,
520
+ extensions,
521
+ mainFields,
522
+ preserveSymlinks,
523
+ useBrowserOverrides,
524
+ baseDir,
525
+ moduleDirectories
526
+ });
527
+ if (resolved) {
528
+ return resolved;
529
+ }
530
+ }
531
+ return null;
532
+ }
533
+
534
+ function handleDeprecatedOptions(opts) {
535
+ const warnings = [];
536
+
537
+ if (opts.customResolveOptions) {
538
+ const { customResolveOptions } = opts;
539
+ if (customResolveOptions.moduleDirectory) {
540
+ // eslint-disable-next-line no-param-reassign
541
+ opts.moduleDirectories = Array.isArray(customResolveOptions.moduleDirectory)
542
+ ? customResolveOptions.moduleDirectory
543
+ : [customResolveOptions.moduleDirectory];
544
+
545
+ warnings.push(
546
+ 'node-resolve: The `customResolveOptions.moduleDirectory` option has been deprecated. Use `moduleDirectories`, which must be an array.'
547
+ );
548
+ }
549
+
550
+ if (customResolveOptions.preserveSymlinks) {
551
+ throw new Error(
552
+ 'node-resolve: `customResolveOptions.preserveSymlinks` is no longer an option. We now always use the rollup `preserveSymlinks` option.'
553
+ );
554
+ }
555
+
556
+ [
557
+ 'basedir',
558
+ 'package',
559
+ 'extensions',
560
+ 'includeCoreModules',
561
+ 'readFile',
562
+ 'isFile',
563
+ 'isDirectory',
564
+ 'realpath',
565
+ 'packageFilter',
566
+ 'pathFilter',
567
+ 'paths',
568
+ 'packageIterator'
569
+ ].forEach((resolveOption) => {
570
+ if (customResolveOptions[resolveOption]) {
571
+ throw new Error(
572
+ `node-resolve: \`customResolveOptions.${resolveOption}\` is no longer an option. If you need this, please open an issue.`
573
+ );
574
+ }
575
+ });
418
576
  }
419
577
 
420
- return promise;
578
+ return { warnings };
421
579
  }
422
580
 
423
- const builtins = new Set(builtinList);
581
+ /* eslint-disable no-param-reassign, no-shadow, no-undefined */
582
+
583
+ const builtins = new Set(builtinList__default['default']);
424
584
  const ES6_BROWSER_EMPTY = '\0node-resolve:empty.js';
585
+ const deepFreeze = (object) => {
586
+ Object.freeze(object);
425
587
 
426
- const nullFn = () => null;
588
+ for (const value of Object.values(object)) {
589
+ if (typeof value === 'object' && !Object.isFrozen(value)) {
590
+ deepFreeze(value);
591
+ }
592
+ }
427
593
 
594
+ return object;
595
+ };
596
+
597
+ const baseConditions = ['default', 'module'];
598
+ const baseConditionsEsm = [...baseConditions, 'import'];
599
+ const baseConditionsCjs = [...baseConditions, 'require'];
428
600
  const defaults = {
429
- customResolveOptions: {},
430
601
  dedupe: [],
431
602
  // It's important that .mjs is listed before .js so that Rollup will interpret npm modules
432
603
  // which deploy both ESM .mjs and CommonJS .js files as ESM.
433
604
  extensions: ['.mjs', '.js', '.json', '.node'],
434
- resolveOnly: []
605
+ resolveOnly: [],
606
+ moduleDirectories: ['node_modules']
435
607
  };
436
- const DEFAULTS = deepFreeze(deepMerge({}, defaults));
608
+ const DEFAULTS = deepFreeze(deepMerge__default['default']({}, defaults));
609
+
437
610
  function nodeResolve(opts = {}) {
438
- const options = Object.assign({}, defaults, opts);
439
- const customResolveOptions = options.customResolveOptions,
440
- extensions = options.extensions,
441
- jail = options.jail;
442
- const warnings = [];
611
+ const { warnings } = handleDeprecatedOptions(opts);
612
+
613
+ const options = { ...defaults, ...opts };
614
+ const { extensions, jail, moduleDirectories } = options;
615
+ const conditionsEsm = [...baseConditionsEsm, ...(options.exportConditions || [])];
616
+ const conditionsCjs = [...baseConditionsCjs, ...(options.exportConditions || [])];
443
617
  const packageInfoCache = new Map();
444
618
  const idToPackageInfo = new Map();
445
619
  const mainFields = getMainFields(options);
@@ -447,49 +621,36 @@ function nodeResolve(opts = {}) {
447
621
  const isPreferBuiltinsSet = options.preferBuiltins === true || options.preferBuiltins === false;
448
622
  const preferBuiltins = isPreferBuiltinsSet ? options.preferBuiltins : true;
449
623
  const rootDir = options.rootDir || process.cwd();
450
- let dedupe = options.dedupe;
624
+ let { dedupe } = options;
451
625
  let rollupOptions;
452
626
 
453
- if (options.only) {
454
- warnings.push('node-resolve: The `only` options is deprecated, please use `resolveOnly`');
455
- options.resolveOnly = options.only;
456
- }
457
-
458
627
  if (typeof dedupe !== 'function') {
459
- dedupe = importee => options.dedupe.includes(importee) || options.dedupe.includes(getPackageName(importee));
628
+ dedupe = (importee) =>
629
+ options.dedupe.includes(importee) || options.dedupe.includes(getPackageName(importee));
460
630
  }
461
631
 
462
- const resolveOnly = options.resolveOnly.map(pattern => {
632
+ const resolveOnly = options.resolveOnly.map((pattern) => {
463
633
  if (pattern instanceof RegExp) {
464
634
  return pattern;
465
635
  }
466
-
467
636
  const normalized = pattern.replace(/[\\^$*+?.()|[\]{}]/g, '\\$&');
468
637
  return new RegExp(`^${normalized}$`);
469
638
  });
639
+
470
640
  const browserMapCache = new Map();
471
641
  let preserveSymlinks;
642
+
472
643
  return {
473
644
  name: 'node-resolve',
474
645
 
475
646
  buildStart(options) {
476
647
  rollupOptions = options;
477
648
 
478
- var _iterator = _createForOfIteratorHelper(warnings),
479
- _step;
480
-
481
- try {
482
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
483
- const warning = _step.value;
484
- this.warn(warning);
485
- }
486
- } catch (err) {
487
- _iterator.e(err);
488
- } finally {
489
- _iterator.f();
649
+ for (const warning of warnings) {
650
+ this.warn(warning);
490
651
  }
491
652
 
492
- preserveSymlinks = options.preserveSymlinks;
653
+ ({ preserveSymlinks } = options);
493
654
  },
494
655
 
495
656
  generateBundle() {
@@ -498,217 +659,194 @@ function nodeResolve(opts = {}) {
498
659
  isDirCached.clear();
499
660
  },
500
661
 
501
- resolveId(importee, importer) {
502
- var _this = this;
503
-
504
- return _asyncToGenerator(function* () {
505
- if (importee === ES6_BROWSER_EMPTY) {
506
- return importee;
507
- } // ignore IDs with null character, these belong to other plugins
508
-
509
-
510
- if (/\0/.test(importee)) return null; // strip hash and query params from import
511
-
512
- const _importee$split = importee.split('#'),
513
- _importee$split2 = _slicedToArray(_importee$split, 2),
514
- withoutHash = _importee$split2[0],
515
- hash = _importee$split2[1];
516
-
517
- const _withoutHash$split = withoutHash.split('?'),
518
- _withoutHash$split2 = _slicedToArray(_withoutHash$split, 2),
519
- importPath = _withoutHash$split2[0],
520
- params = _withoutHash$split2[1];
521
-
522
- const importSuffix = `${params ? `?${params}` : ''}${hash ? `#${hash}` : ''}`;
523
- importee = importPath;
524
- const basedir = !importer || dedupe(importee) ? rootDir : path.dirname(importer); // https://github.com/defunctzombie/package-browser-field-spec
525
-
526
- const browser = browserMapCache.get(importer);
527
-
528
- if (useBrowserOverrides && browser) {
529
- const resolvedImportee = path.resolve(basedir, importee);
530
-
531
- if (browser[importee] === false || browser[resolvedImportee] === false) {
532
- return ES6_BROWSER_EMPTY;
533
- }
534
-
535
- const browserImportee = browser[importee] || browser[resolvedImportee] || browser[`${resolvedImportee}.js`] || browser[`${resolvedImportee}.json`];
662
+ async resolveId(importee, importer, opts) {
663
+ if (importee === ES6_BROWSER_EMPTY) {
664
+ return importee;
665
+ }
666
+ // ignore IDs with null character, these belong to other plugins
667
+ if (/\0/.test(importee)) return null;
536
668
 
537
- if (browserImportee) {
538
- importee = browserImportee;
539
- }
540
- }
669
+ if (/\0/.test(importer)) {
670
+ importer = undefined;
671
+ }
541
672
 
542
- const parts = importee.split(/[/\\]/);
543
- let id = parts.shift();
544
- let isRelativeImport = false;
545
-
546
- if (id[0] === '@' && parts.length > 0) {
547
- // scoped packages
548
- id += `/${parts.shift()}`;
549
- } else if (id[0] === '.') {
550
- // an import relative to the parent dir of the importer
551
- id = path.resolve(basedir, importee);
552
- isRelativeImport = true;
553
- }
673
+ // strip query params from import
674
+ const [importPath, params] = importee.split('?');
675
+ const importSuffix = `${params ? `?${params}` : ''}`;
676
+ importee = importPath;
554
677
 
555
- if (!isRelativeImport && resolveOnly.length && !resolveOnly.some(pattern => pattern.test(id))) {
556
- if (normalizeInput(rollupOptions.input).includes(importee)) {
557
- return null;
558
- }
678
+ const baseDir = !importer || dedupe(importee) ? rootDir : path.dirname(importer);
559
679
 
560
- return false;
680
+ // https://github.com/defunctzombie/package-browser-field-spec
681
+ const browser = browserMapCache.get(importer);
682
+ if (useBrowserOverrides && browser) {
683
+ const resolvedImportee = path.resolve(baseDir, importee);
684
+ if (browser[importee] === false || browser[resolvedImportee] === false) {
685
+ return ES6_BROWSER_EMPTY;
561
686
  }
562
-
563
- let hasModuleSideEffects = nullFn;
564
- let hasPackageEntry = true;
565
- let packageBrowserField = false;
566
- let packageInfo;
567
-
568
- const filter = (pkg, pkgPath) => {
569
- const info = getPackageInfo({
570
- cache: packageInfoCache,
571
- extensions,
572
- pkg,
573
- pkgPath,
574
- mainFields,
575
- preserveSymlinks,
576
- useBrowserOverrides
577
- });
578
- packageInfo = info.packageInfo;
579
- hasModuleSideEffects = info.hasModuleSideEffects;
580
- hasPackageEntry = info.hasPackageEntry;
581
- packageBrowserField = info.packageBrowserField;
582
- return info.cachedPkg;
583
- };
584
-
585
- let resolveOptions = {
586
- basedir,
587
- packageFilter: filter,
588
- readFile: readCachedFile,
589
- isFile: isFileCached,
590
- isDirectory: isDirCached,
591
- extensions
592
- };
593
-
594
- if (preserveSymlinks !== undefined) {
595
- resolveOptions.preserveSymlinks = preserveSymlinks;
687
+ const browserImportee =
688
+ browser[importee] ||
689
+ browser[resolvedImportee] ||
690
+ browser[`${resolvedImportee}.js`] ||
691
+ browser[`${resolvedImportee}.json`];
692
+ if (browserImportee) {
693
+ importee = browserImportee;
596
694
  }
695
+ }
597
696
 
598
- const importSpecifierList = [];
697
+ const parts = importee.split(/[/\\]/);
698
+ let id = parts.shift();
699
+ let isRelativeImport = false;
700
+
701
+ if (id[0] === '@' && parts.length > 0) {
702
+ // scoped packages
703
+ id += `/${parts.shift()}`;
704
+ } else if (id[0] === '.') {
705
+ // an import relative to the parent dir of the importer
706
+ id = path.resolve(baseDir, importee);
707
+ isRelativeImport = true;
708
+ }
599
709
 
600
- if (importer === undefined && !importee[0].match(/^\.?\.?\//)) {
601
- // For module graph roots (i.e. when importer is undefined), we
602
- // need to handle 'path fragments` like `foo/bar` that are commonly
603
- // found in rollup config files. If importee doesn't look like a
604
- // relative or absolute path, we make it relative and attempt to
605
- // resolve it. If we don't find anything, we try resolving it as we
606
- // got it.
607
- importSpecifierList.push(`./${importee}`);
710
+ if (
711
+ !isRelativeImport &&
712
+ resolveOnly.length &&
713
+ !resolveOnly.some((pattern) => pattern.test(id))
714
+ ) {
715
+ if (normalizeInput(rollupOptions.input).includes(importee)) {
716
+ return null;
608
717
  }
718
+ return false;
719
+ }
609
720
 
610
- const importeeIsBuiltin = builtins.has(importee);
721
+ const importSpecifierList = [];
611
722
 
612
- if (importeeIsBuiltin && (!preferBuiltins || !isPreferBuiltinsSet)) {
613
- // The `resolve` library will not resolve packages with the same
614
- // name as a node built-in module. If we're resolving something
615
- // that's a builtin, and we don't prefer to find built-ins, we
616
- // first try to look up a local module with that name. If we don't
617
- // find anything, we resolve the builtin which just returns back
618
- // the built-in's name.
619
- importSpecifierList.push(`${importee}/`);
620
- } // TypeScript files may import '.js' to refer to either '.ts' or '.tsx'
723
+ if (importer === undefined && !importee[0].match(/^\.?\.?\//)) {
724
+ // For module graph roots (i.e. when importer is undefined), we
725
+ // need to handle 'path fragments` like `foo/bar` that are commonly
726
+ // found in rollup config files. If importee doesn't look like a
727
+ // relative or absolute path, we make it relative and attempt to
728
+ // resolve it. If we don't find anything, we try resolving it as we
729
+ // got it.
730
+ importSpecifierList.push(`./${importee}`);
731
+ }
621
732
 
733
+ const importeeIsBuiltin = builtins.has(importee);
622
734
 
623
- if (importer && importee.endsWith('.js')) {
624
- for (var _i = 0, _arr = ['.ts', '.tsx']; _i < _arr.length; _i++) {
625
- const ext = _arr[_i];
735
+ if (importeeIsBuiltin) {
736
+ // The `resolve` library will not resolve packages with the same
737
+ // name as a node built-in module. If we're resolving something
738
+ // that's a builtin, and we don't prefer to find built-ins, we
739
+ // first try to look up a local module with that name. If we don't
740
+ // find anything, we resolve the builtin which just returns back
741
+ // the built-in's name.
742
+ importSpecifierList.push(`${importee}/`);
743
+ }
626
744
 
627
- if (importer.endsWith(ext) && extensions.includes(ext)) {
628
- importSpecifierList.push(importee.replace(/.js$/, ext));
629
- }
745
+ // TypeScript files may import '.js' to refer to either '.ts' or '.tsx'
746
+ if (importer && importee.endsWith('.js')) {
747
+ for (const ext of ['.ts', '.tsx']) {
748
+ if (importer.endsWith(ext) && extensions.includes(ext)) {
749
+ importSpecifierList.push(importee.replace(/.js$/, ext));
630
750
  }
631
751
  }
752
+ }
632
753
 
633
- importSpecifierList.push(importee);
634
- resolveOptions = Object.assign(resolveOptions, customResolveOptions);
635
-
636
- try {
637
- let resolved = yield resolveImportSpecifiers(importSpecifierList, resolveOptions);
638
-
639
- if (resolved && packageBrowserField) {
640
- if (Object.prototype.hasOwnProperty.call(packageBrowserField, resolved)) {
641
- if (!packageBrowserField[resolved]) {
642
- browserMapCache.set(resolved, packageBrowserField);
643
- return ES6_BROWSER_EMPTY;
644
- }
645
-
646
- resolved = packageBrowserField[resolved];
647
- }
648
-
649
- browserMapCache.set(resolved, packageBrowserField);
650
- }
651
-
652
- if (hasPackageEntry && !preserveSymlinks && resolved) {
653
- const fileExists = yield exists(resolved);
754
+ importSpecifierList.push(importee);
755
+
756
+ const warn = (...args) => this.warn(...args);
757
+ const isRequire =
758
+ opts && opts.custom && opts.custom['node-resolve'] && opts.custom['node-resolve'].isRequire;
759
+ const exportConditions = isRequire ? conditionsCjs : conditionsEsm;
760
+
761
+ const resolvedWithoutBuiltins = await resolveImportSpecifiers({
762
+ importer,
763
+ importSpecifierList,
764
+ exportConditions,
765
+ warn,
766
+ packageInfoCache,
767
+ extensions,
768
+ mainFields,
769
+ preserveSymlinks,
770
+ useBrowserOverrides,
771
+ baseDir,
772
+ moduleDirectories
773
+ });
654
774
 
655
- if (fileExists) {
656
- resolved = yield realpath(resolved);
775
+ const resolved =
776
+ importeeIsBuiltin && preferBuiltins
777
+ ? {
778
+ packageInfo: undefined,
779
+ hasModuleSideEffects: () => null,
780
+ hasPackageEntry: true,
781
+ packageBrowserField: false
657
782
  }
658
- }
659
-
660
- idToPackageInfo.set(resolved, packageInfo);
661
-
662
- if (hasPackageEntry) {
663
- if (builtins.has(resolved) && preferBuiltins && isPreferBuiltinsSet) {
664
- return null;
665
- } else if (importeeIsBuiltin && preferBuiltins) {
666
- if (!isPreferBuiltinsSet) {
667
- _this.warn(`preferring built-in module '${importee}' over local alternative at '${resolved}', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning`);
668
- }
783
+ : resolvedWithoutBuiltins;
784
+ if (!resolved) {
785
+ return null;
786
+ }
669
787
 
670
- return null;
671
- } else if (jail && resolved.indexOf(path.normalize(jail.trim(path.sep))) !== 0) {
672
- return null;
673
- }
788
+ const { packageInfo, hasModuleSideEffects, hasPackageEntry, packageBrowserField } = resolved;
789
+ let { location } = resolved;
790
+ if (packageBrowserField) {
791
+ if (Object.prototype.hasOwnProperty.call(packageBrowserField, location)) {
792
+ if (!packageBrowserField[location]) {
793
+ browserMapCache.set(location, packageBrowserField);
794
+ return ES6_BROWSER_EMPTY;
674
795
  }
796
+ location = packageBrowserField[location];
797
+ }
798
+ browserMapCache.set(location, packageBrowserField);
799
+ }
675
800
 
676
- if (resolved && options.modulesOnly) {
677
- const code = yield readFile(resolved, 'utf-8');
801
+ if (hasPackageEntry && !preserveSymlinks) {
802
+ const fileExists = await exists(location);
803
+ if (fileExists) {
804
+ location = await realpath(location);
805
+ }
806
+ }
678
807
 
679
- if (isModule(code)) {
680
- return {
681
- id: `${resolved}${importSuffix}`,
682
- moduleSideEffects: hasModuleSideEffects(resolved)
683
- };
684
- }
808
+ idToPackageInfo.set(location, packageInfo);
685
809
 
686
- return null;
810
+ if (hasPackageEntry) {
811
+ if (importeeIsBuiltin && preferBuiltins) {
812
+ if (!isPreferBuiltinsSet && resolvedWithoutBuiltins && resolved !== importee) {
813
+ this.warn(
814
+ `preferring built-in module '${importee}' over local alternative at '${resolvedWithoutBuiltins.location}', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning`
815
+ );
687
816
  }
817
+ return false;
818
+ } else if (jail && location.indexOf(path.normalize(jail.trim(path.sep))) !== 0) {
819
+ return null;
820
+ }
821
+ }
688
822
 
689
- const result = {
690
- id: `${resolved}${importSuffix}`,
691
- moduleSideEffects: hasModuleSideEffects(resolved)
823
+ if (options.modulesOnly && (await exists(location))) {
824
+ const code = await readFile(location, 'utf-8');
825
+ if (isModule__default['default'](code)) {
826
+ return {
827
+ id: `${location}${importSuffix}`,
828
+ moduleSideEffects: hasModuleSideEffects(location)
692
829
  };
693
- return result;
694
- } catch (error) {
695
- return null;
696
830
  }
697
- })();
831
+ return null;
832
+ }
833
+ const result = {
834
+ id: `${location}${importSuffix}`,
835
+ moduleSideEffects: hasModuleSideEffects(location)
836
+ };
837
+ return result;
698
838
  },
699
839
 
700
840
  load(importee) {
701
841
  if (importee === ES6_BROWSER_EMPTY) {
702
842
  return 'export default {};';
703
843
  }
704
-
705
844
  return null;
706
845
  },
707
846
 
708
847
  getPackageInfoForId(id) {
709
848
  return idToPackageInfo.get(id);
710
849
  }
711
-
712
850
  };
713
851
  }
714
852