1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | 'use strict';
|
9 |
|
10 | Object.defineProperty(exports, '__esModule', { value: true });
|
11 |
|
12 | const path = require('path');
|
13 | const fs = require('fs');
|
14 | const hash = require('hash-sum');
|
15 | const consola = require('consola');
|
16 | const utilsEdge = require('@nuxt/utils-edge');
|
17 | const Hookable = require('hable');
|
18 | const configEdge = require('@nuxt/config-edge');
|
19 | const serverEdge = require('@nuxt/server-edge');
|
20 | const fs$1 = require('fs-extra');
|
21 |
|
22 | function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
23 |
|
24 | const path__default = _interopDefaultLegacy(path);
|
25 | const fs__default = _interopDefaultLegacy(fs);
|
26 | const hash__default = _interopDefaultLegacy(hash);
|
27 | const consola__default = _interopDefaultLegacy(consola);
|
28 | const Hookable__default = _interopDefaultLegacy(Hookable);
|
29 | const fs__default$1 = _interopDefaultLegacy(fs$1);
|
30 |
|
31 | class ModuleContainer {
|
32 | constructor (nuxt) {
|
33 | this.nuxt = nuxt;
|
34 | this.options = nuxt.options;
|
35 | this.requiredModules = {};
|
36 |
|
37 |
|
38 | for (const method of Object.getOwnPropertyNames(ModuleContainer.prototype)) {
|
39 | if (typeof this[method] === 'function') {
|
40 | this[method] = this[method].bind(this);
|
41 | }
|
42 | }
|
43 | }
|
44 |
|
45 | async ready () {
|
46 |
|
47 | await this.nuxt.callHook('modules:before', this, this.options.modules);
|
48 |
|
49 | if (this.options.buildModules && !this.options._start) {
|
50 |
|
51 | await utilsEdge.sequence(this.options.buildModules, this.addModule);
|
52 | }
|
53 |
|
54 |
|
55 | await utilsEdge.sequence(this.options.modules, this.addModule);
|
56 |
|
57 |
|
58 | await utilsEdge.sequence(this.options._modules, this.addModule);
|
59 |
|
60 |
|
61 | await this.nuxt.callHook('modules:done', this);
|
62 | }
|
63 |
|
64 | addVendor () {
|
65 | consola__default['default'].warn('addVendor has been deprecated due to webpack4 optimization');
|
66 | }
|
67 |
|
68 | addTemplate (template) {
|
69 | if (!template) {
|
70 | throw new Error('Invalid template: ' + JSON.stringify(template))
|
71 | }
|
72 |
|
73 |
|
74 | const src = template.src || template;
|
75 | const srcPath = path__default['default'].parse(src);
|
76 |
|
77 | if (typeof src !== 'string' || !fs__default['default'].existsSync(src)) {
|
78 | throw new Error('Template src not found: ' + src)
|
79 | }
|
80 |
|
81 |
|
82 | const fileName = template.fileName || template.filename;
|
83 |
|
84 | const dst = fileName || `${path__default['default'].basename(srcPath.dir)}.${srcPath.name}.${hash__default['default'](src)}${srcPath.ext}`;
|
85 |
|
86 | const templateObj = {
|
87 | src,
|
88 | dst,
|
89 | options: template.options
|
90 | };
|
91 |
|
92 | this.options.build.templates.push(templateObj);
|
93 |
|
94 | return templateObj
|
95 | }
|
96 |
|
97 | addPlugin (template) {
|
98 | const { dst } = this.addTemplate(template);
|
99 |
|
100 |
|
101 | this.options.plugins.unshift({
|
102 | src: path__default['default'].join(this.options.buildDir, dst),
|
103 |
|
104 | ssr: template.ssr,
|
105 | mode: template.mode
|
106 | });
|
107 | }
|
108 |
|
109 | addLayout (template, name) {
|
110 | const { dst, src } = this.addTemplate(template);
|
111 | const layoutName = name || path__default['default'].parse(src).name;
|
112 | const layout = this.options.layouts[layoutName];
|
113 |
|
114 | if (layout) {
|
115 | consola__default['default'].warn(`Duplicate layout registration, "${layoutName}" has been registered as "${layout}"`);
|
116 | }
|
117 |
|
118 |
|
119 | this.options.layouts[layoutName] = `./${dst}`;
|
120 |
|
121 |
|
122 | if (name === 'error') {
|
123 | this.addErrorLayout(dst);
|
124 | }
|
125 | }
|
126 |
|
127 | addErrorLayout (dst) {
|
128 | const relativeBuildDir = path__default['default'].relative(this.options.rootDir, this.options.buildDir);
|
129 | this.options.ErrorPage = `~/${relativeBuildDir}/${dst}`;
|
130 | }
|
131 |
|
132 | addServerMiddleware (middleware) {
|
133 | this.options.serverMiddleware.push(middleware);
|
134 | }
|
135 |
|
136 | extendBuild (fn) {
|
137 | this.options.build.extend = utilsEdge.chainFn(this.options.build.extend, fn);
|
138 | }
|
139 |
|
140 | extendRoutes (fn) {
|
141 | this.options.router.extendRoutes = utilsEdge.chainFn(
|
142 | this.options.router.extendRoutes,
|
143 | fn
|
144 | );
|
145 | }
|
146 |
|
147 | requireModule (moduleOpts) {
|
148 | return this.addModule(moduleOpts)
|
149 | }
|
150 |
|
151 | async addModule (moduleOpts) {
|
152 | let src;
|
153 | let options;
|
154 | let handler;
|
155 |
|
156 |
|
157 | if (typeof moduleOpts === 'string' || typeof moduleOpts === 'function') {
|
158 | src = moduleOpts;
|
159 | } else if (Array.isArray(moduleOpts)) {
|
160 |
|
161 | [src, options] = moduleOpts;
|
162 | } else if (typeof moduleOpts === 'object') {
|
163 |
|
164 | ({ src, options, handler } = moduleOpts);
|
165 | }
|
166 |
|
167 |
|
168 | if (typeof src === 'function') {
|
169 | handler = src;
|
170 | }
|
171 |
|
172 |
|
173 | if (this.options.buildModules.includes(handler) && this.options._start) {
|
174 | return
|
175 | }
|
176 |
|
177 |
|
178 | if (!handler) {
|
179 | try {
|
180 | handler = this.nuxt.resolver.requireModule(src, { useESM: true });
|
181 | } catch (error) {
|
182 | if (error.code !== 'MODULE_NOT_FOUND') {
|
183 | throw error
|
184 | }
|
185 |
|
186 |
|
187 | if (error.message.includes(src) && !/^[~.]|^@\//.test(src)) {
|
188 | let message = 'Module `{name}` not found.';
|
189 |
|
190 | if (this.options.buildModules.includes(src)) {
|
191 | message += ' Please ensure `{name}` is in `devDependencies` and installed. HINT: During build step, for npm/yarn, `NODE_ENV=production` or `--production` should NOT be used.'.replace('{name}', src);
|
192 | } else if (this.options.modules.includes(src)) {
|
193 | message += ' Please ensure `{name}` is in `dependencies` and installed.';
|
194 | }
|
195 |
|
196 | message = message.replace(/{name}/g, src);
|
197 |
|
198 | consola__default['default'].warn(message);
|
199 | }
|
200 |
|
201 | if (this.options._cli) {
|
202 | throw error
|
203 | } else {
|
204 |
|
205 | consola__default['default'].warn('Silently ignoring module as programatic usage detected.');
|
206 | return
|
207 | }
|
208 | }
|
209 | }
|
210 |
|
211 |
|
212 | if (typeof handler !== 'function') {
|
213 | throw new TypeError('Module should export a function: ' + src)
|
214 | }
|
215 |
|
216 |
|
217 | const metaKey = handler.meta && handler.meta.name;
|
218 | const key = metaKey || src;
|
219 | if (typeof key === 'string') {
|
220 | if (this.requiredModules[key]) {
|
221 | if (!metaKey) {
|
222 |
|
223 | consola__default['default'].warn('Modules should be only specified once:', key);
|
224 | } else {
|
225 | return
|
226 | }
|
227 | }
|
228 | this.requiredModules[key] = { src, options, handler };
|
229 | }
|
230 |
|
231 |
|
232 | if (options === undefined) {
|
233 | options = {};
|
234 | }
|
235 | const result = await handler.call(this, options);
|
236 | return result
|
237 | }
|
238 | }
|
239 |
|
240 | var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
241 |
|
242 |
|
243 | var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
244 |
|
245 | var _freeGlobal = freeGlobal;
|
246 |
|
247 |
|
248 | var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
249 |
|
250 |
|
251 | var root = _freeGlobal || freeSelf || Function('return this')();
|
252 |
|
253 | var _root = root;
|
254 |
|
255 |
|
256 | var Symbol = _root.Symbol;
|
257 |
|
258 | var _Symbol = Symbol;
|
259 |
|
260 |
|
261 | var objectProto = Object.prototype;
|
262 |
|
263 |
|
264 | var hasOwnProperty = objectProto.hasOwnProperty;
|
265 |
|
266 |
|
267 |
|
268 |
|
269 |
|
270 |
|
271 | var nativeObjectToString = objectProto.toString;
|
272 |
|
273 |
|
274 | var symToStringTag = _Symbol ? _Symbol.toStringTag : undefined;
|
275 |
|
276 |
|
277 |
|
278 |
|
279 |
|
280 |
|
281 |
|
282 |
|
283 | function getRawTag(value) {
|
284 | var isOwn = hasOwnProperty.call(value, symToStringTag),
|
285 | tag = value[symToStringTag];
|
286 |
|
287 | try {
|
288 | value[symToStringTag] = undefined;
|
289 | var unmasked = true;
|
290 | } catch (e) {}
|
291 |
|
292 | var result = nativeObjectToString.call(value);
|
293 | if (unmasked) {
|
294 | if (isOwn) {
|
295 | value[symToStringTag] = tag;
|
296 | } else {
|
297 | delete value[symToStringTag];
|
298 | }
|
299 | }
|
300 | return result;
|
301 | }
|
302 |
|
303 | var _getRawTag = getRawTag;
|
304 |
|
305 |
|
306 | var objectProto$1 = Object.prototype;
|
307 |
|
308 |
|
309 |
|
310 |
|
311 |
|
312 |
|
313 | var nativeObjectToString$1 = objectProto$1.toString;
|
314 |
|
315 |
|
316 |
|
317 |
|
318 |
|
319 |
|
320 |
|
321 |
|
322 | function objectToString(value) {
|
323 | return nativeObjectToString$1.call(value);
|
324 | }
|
325 |
|
326 | var _objectToString = objectToString;
|
327 |
|
328 |
|
329 | var nullTag = '[object Null]',
|
330 | undefinedTag = '[object Undefined]';
|
331 |
|
332 |
|
333 | var symToStringTag$1 = _Symbol ? _Symbol.toStringTag : undefined;
|
334 |
|
335 |
|
336 |
|
337 |
|
338 |
|
339 |
|
340 |
|
341 |
|
342 | function baseGetTag(value) {
|
343 | if (value == null) {
|
344 | return value === undefined ? undefinedTag : nullTag;
|
345 | }
|
346 | return (symToStringTag$1 && symToStringTag$1 in Object(value))
|
347 | ? _getRawTag(value)
|
348 | : _objectToString(value);
|
349 | }
|
350 |
|
351 | var _baseGetTag = baseGetTag;
|
352 |
|
353 |
|
354 |
|
355 |
|
356 |
|
357 |
|
358 |
|
359 |
|
360 |
|
361 | function overArg(func, transform) {
|
362 | return function(arg) {
|
363 | return func(transform(arg));
|
364 | };
|
365 | }
|
366 |
|
367 | var _overArg = overArg;
|
368 |
|
369 |
|
370 | var getPrototype = _overArg(Object.getPrototypeOf, Object);
|
371 |
|
372 | var _getPrototype = getPrototype;
|
373 |
|
374 |
|
375 |
|
376 |
|
377 |
|
378 |
|
379 |
|
380 |
|
381 |
|
382 |
|
383 |
|
384 |
|
385 |
|
386 |
|
387 |
|
388 |
|
389 |
|
390 |
|
391 |
|
392 |
|
393 |
|
394 |
|
395 |
|
396 |
|
397 |
|
398 | function isObjectLike(value) {
|
399 | return value != null && typeof value == 'object';
|
400 | }
|
401 |
|
402 | var isObjectLike_1 = isObjectLike;
|
403 |
|
404 |
|
405 | var objectTag = '[object Object]';
|
406 |
|
407 |
|
408 | var funcProto = Function.prototype,
|
409 | objectProto$2 = Object.prototype;
|
410 |
|
411 |
|
412 | var funcToString = funcProto.toString;
|
413 |
|
414 |
|
415 | var hasOwnProperty$1 = objectProto$2.hasOwnProperty;
|
416 |
|
417 |
|
418 | var objectCtorString = funcToString.call(Object);
|
419 |
|
420 |
|
421 |
|
422 |
|
423 |
|
424 |
|
425 |
|
426 |
|
427 |
|
428 |
|
429 |
|
430 |
|
431 |
|
432 |
|
433 |
|
434 |
|
435 |
|
436 |
|
437 |
|
438 |
|
439 |
|
440 |
|
441 |
|
442 |
|
443 |
|
444 |
|
445 |
|
446 |
|
447 |
|
448 | function isPlainObject(value) {
|
449 | if (!isObjectLike_1(value) || _baseGetTag(value) != objectTag) {
|
450 | return false;
|
451 | }
|
452 | var proto = _getPrototype(value);
|
453 | if (proto === null) {
|
454 | return true;
|
455 | }
|
456 | var Ctor = hasOwnProperty$1.call(proto, 'constructor') && proto.constructor;
|
457 | return typeof Ctor == 'function' && Ctor instanceof Ctor &&
|
458 | funcToString.call(Ctor) == objectCtorString;
|
459 | }
|
460 |
|
461 | var isPlainObject_1 = isPlainObject;
|
462 |
|
463 | var version = "2.14.8-26723562.046a0a4b";
|
464 |
|
465 | class Resolver {
|
466 | constructor (nuxt) {
|
467 | this.nuxt = nuxt;
|
468 | this.options = this.nuxt.options;
|
469 |
|
470 |
|
471 | this.resolvePath = this.resolvePath.bind(this);
|
472 | this.resolveAlias = this.resolveAlias.bind(this);
|
473 | this.resolveModule = this.resolveModule.bind(this);
|
474 | this.requireModule = this.requireModule.bind(this);
|
475 |
|
476 | const { createRequire } = this.options;
|
477 | this._require = createRequire ? createRequire(module) : module.require;
|
478 |
|
479 | this._resolve = require.resolve;
|
480 | }
|
481 |
|
482 | resolveModule (path) {
|
483 | try {
|
484 | return this._resolve(path, {
|
485 | paths: this.options.modulesDir
|
486 | })
|
487 | } catch (error) {
|
488 | if (error.code !== 'MODULE_NOT_FOUND') {
|
489 |
|
490 | if (process.env.NODE_ENV === 'test' && error.message.startsWith('Cannot resolve module')) {
|
491 | return
|
492 | }
|
493 | throw error
|
494 | }
|
495 | }
|
496 | }
|
497 |
|
498 | resolveAlias (path$1) {
|
499 | if (utilsEdge.startsWithRootAlias(path$1)) {
|
500 | return path.join(this.options.rootDir, path$1.substr(2))
|
501 | }
|
502 |
|
503 | if (utilsEdge.startsWithSrcAlias(path$1)) {
|
504 | return path.join(this.options.srcDir, path$1.substr(1))
|
505 | }
|
506 |
|
507 | return path.resolve(this.options.srcDir, path$1)
|
508 | }
|
509 |
|
510 | resolvePath (path$1, { alias, isAlias = alias, module, isModule = module, isStyle } = {}) {
|
511 |
|
512 | if (alias) {
|
513 | consola__default['default'].warn('Using alias is deprecated and will be removed in Nuxt 3. Use `isAlias` instead.');
|
514 | }
|
515 | if (module) {
|
516 | consola__default['default'].warn('Using module is deprecated and will be removed in Nuxt 3. Use `isModule` instead.');
|
517 | }
|
518 |
|
519 |
|
520 | if (fs__default$1['default'].existsSync(path$1)) {
|
521 | return path$1
|
522 | }
|
523 |
|
524 | let resolvedPath;
|
525 |
|
526 |
|
527 | if (isModule !== false) {
|
528 | resolvedPath = this.resolveModule(path$1);
|
529 | }
|
530 |
|
531 |
|
532 | if (!resolvedPath && isAlias !== false) {
|
533 | resolvedPath = this.resolveAlias(path$1);
|
534 | }
|
535 |
|
536 |
|
537 | if (!resolvedPath) {
|
538 | resolvedPath = path$1;
|
539 | }
|
540 |
|
541 | let isDirectory;
|
542 |
|
543 |
|
544 | if (fs__default$1['default'].existsSync(resolvedPath)) {
|
545 | isDirectory = fs__default$1['default'].lstatSync(resolvedPath).isDirectory();
|
546 |
|
547 | if (!isDirectory) {
|
548 | return resolvedPath
|
549 | }
|
550 | }
|
551 |
|
552 | const extensions = isStyle ? this.options.styleExtensions : this.options.extensions;
|
553 |
|
554 |
|
555 | for (const ext of extensions) {
|
556 | if (!isDirectory && fs__default$1['default'].existsSync(resolvedPath + '.' + ext)) {
|
557 | return resolvedPath + '.' + ext
|
558 | }
|
559 |
|
560 | const resolvedPathwithIndex = path.join(resolvedPath, 'index.' + ext);
|
561 | if (isDirectory && fs__default$1['default'].existsSync(resolvedPathwithIndex)) {
|
562 | return resolvedPathwithIndex
|
563 | }
|
564 | }
|
565 |
|
566 |
|
567 | if (isDirectory) {
|
568 | return resolvedPath
|
569 | }
|
570 |
|
571 |
|
572 | throw new Error(`Cannot resolve "${path$1}" from "${resolvedPath}"`)
|
573 | }
|
574 |
|
575 | requireModule (path, { esm, useESM = esm, alias, isAlias = alias, intropDefault, interopDefault = intropDefault } = {}) {
|
576 | let resolvedPath = path;
|
577 | let requiredModule;
|
578 |
|
579 |
|
580 | if (intropDefault) {
|
581 | consola__default['default'].warn('Using intropDefault is deprecated and will be removed in Nuxt 3. Use `interopDefault` instead.');
|
582 | }
|
583 | if (alias) {
|
584 | consola__default['default'].warn('Using alias is deprecated and will be removed in Nuxt 3. Use `isAlias` instead.');
|
585 | }
|
586 | if (esm) {
|
587 | consola__default['default'].warn('Using esm is deprecated and will be removed in Nuxt 3. Use `useESM` instead.');
|
588 | }
|
589 |
|
590 | let lastError;
|
591 |
|
592 |
|
593 | try {
|
594 | resolvedPath = this.resolvePath(path, { isAlias });
|
595 | } catch (e) {
|
596 | lastError = e;
|
597 | }
|
598 |
|
599 | const isExternal = utilsEdge.isExternalDependency(resolvedPath);
|
600 |
|
601 |
|
602 |
|
603 | if (this.options.dev && !isExternal) {
|
604 | utilsEdge.clearRequireCache(resolvedPath);
|
605 | }
|
606 |
|
607 |
|
608 | if (useESM === undefined) {
|
609 | useESM = !isExternal && /.(js|mjs)$/.test(resolvedPath);
|
610 | }
|
611 |
|
612 |
|
613 | try {
|
614 | if (useESM) {
|
615 | requiredModule = this._require(resolvedPath);
|
616 | } else {
|
617 | requiredModule = require(resolvedPath);
|
618 | }
|
619 | } catch (e) {
|
620 | lastError = e;
|
621 | }
|
622 |
|
623 |
|
624 | if (interopDefault !== false && requiredModule && requiredModule.default) {
|
625 | requiredModule = requiredModule.default;
|
626 | }
|
627 |
|
628 |
|
629 | if (requiredModule === undefined && lastError) {
|
630 | throw lastError
|
631 | }
|
632 |
|
633 | return requiredModule
|
634 | }
|
635 | }
|
636 |
|
637 | class Nuxt extends Hookable__default['default'] {
|
638 | constructor (options = {}) {
|
639 | super(consola__default['default']);
|
640 |
|
641 |
|
642 | this.options = configEdge.getNuxtConfig(options);
|
643 |
|
644 |
|
645 | this.resolver = new Resolver(this);
|
646 | this.moduleContainer = new ModuleContainer(this);
|
647 |
|
648 |
|
649 | this.deprecateHooks({
|
650 |
|
651 | 'render:context': {
|
652 | to: '_render:context',
|
653 | message: '`render:context(nuxt)` is deprecated, Please use `vue-renderer:ssr:context(context)`'
|
654 | },
|
655 |
|
656 | 'render:routeContext': {
|
657 | to: '_render:context',
|
658 | message: '`render:routeContext(nuxt)` is deprecated, Please use `vue-renderer:ssr:context(context)`'
|
659 | },
|
660 | showReady: 'webpack:done',
|
661 |
|
662 | 'export:done': 'generate:done',
|
663 | 'export:before': 'generate:before',
|
664 | 'export:extendRoutes': 'generate:extendRoutes',
|
665 | 'export:distRemoved': 'generate:distRemoved',
|
666 | 'export:distCopied': 'generate:distCopied',
|
667 | 'export:route': 'generate:route',
|
668 | 'export:routeFailed': 'generate:routeFailed',
|
669 | 'export:page': 'generate:page',
|
670 | 'export:routeCreated': 'generate:routeCreated'
|
671 | });
|
672 |
|
673 |
|
674 | utilsEdge.defineAlias(this, this.resolver, ['resolveAlias', 'resolvePath']);
|
675 | this.showReady = () => { this.callHook('webpack:done'); };
|
676 |
|
677 |
|
678 | if (this.options.server !== false) {
|
679 | this._initServer();
|
680 | }
|
681 |
|
682 |
|
683 | if (this.options._ready !== false) {
|
684 | this.ready().catch((err) => {
|
685 | consola__default['default'].fatal(err);
|
686 | });
|
687 | }
|
688 | }
|
689 |
|
690 | static get version () {
|
691 | return `v${version}` + (global.__NUXT_DEV__ ? '-development' : '')
|
692 | }
|
693 |
|
694 | ready () {
|
695 | if (!this._ready) {
|
696 | this._ready = this._init();
|
697 | }
|
698 | return this._ready
|
699 | }
|
700 |
|
701 | async _init () {
|
702 | if (this._initCalled) {
|
703 | return this
|
704 | }
|
705 | this._initCalled = true;
|
706 |
|
707 |
|
708 | if (isPlainObject_1(this.options.hooks)) {
|
709 | this.addHooks(this.options.hooks);
|
710 | } else if (typeof this.options.hooks === 'function') {
|
711 | this.options.hooks(this.hook);
|
712 | }
|
713 |
|
714 |
|
715 | await this.moduleContainer.ready();
|
716 |
|
717 |
|
718 | if (this.server) {
|
719 | await this.server.ready();
|
720 | }
|
721 |
|
722 |
|
723 | await this.callHook('ready', this);
|
724 |
|
725 | return this
|
726 | }
|
727 |
|
728 | _initServer () {
|
729 | if (this.server) {
|
730 | return
|
731 | }
|
732 | this.server = new serverEdge.Server(this);
|
733 | this.renderer = this.server;
|
734 | this.render = this.server.app;
|
735 | utilsEdge.defineAlias(this, this.server, ['renderRoute', 'renderAndGetWindow', 'listen']);
|
736 | }
|
737 |
|
738 | async close (callback) {
|
739 | await this.callHook('close', this);
|
740 |
|
741 | if (typeof callback === 'function') {
|
742 | await callback();
|
743 | }
|
744 |
|
745 | this.clearHooks();
|
746 | }
|
747 | }
|
748 |
|
749 | const OVERRIDES = {
|
750 | dry: { dev: false, server: false },
|
751 | dev: { dev: true, _build: true },
|
752 | build: { dev: false, server: false, _build: true },
|
753 | start: { dev: false, _start: true }
|
754 | };
|
755 |
|
756 | async function loadNuxt (loadOptions) {
|
757 |
|
758 | if (typeof loadOptions === 'string') {
|
759 | loadOptions = { for: loadOptions };
|
760 | }
|
761 | const { ready = true } = loadOptions;
|
762 | const _for = loadOptions.for || 'dry';
|
763 |
|
764 |
|
765 | const override = OVERRIDES[_for];
|
766 |
|
767 |
|
768 | if (!override) {
|
769 | throw new Error('Unsupported for: ' + _for)
|
770 | }
|
771 |
|
772 |
|
773 | const config = await configEdge.loadNuxtConfig(loadOptions);
|
774 |
|
775 |
|
776 | Object.assign(config, override);
|
777 |
|
778 |
|
779 | const nuxt = new Nuxt(config);
|
780 | if (ready) {
|
781 | await nuxt.ready();
|
782 | }
|
783 |
|
784 | return nuxt
|
785 | }
|
786 |
|
787 | Object.defineProperty(exports, 'loadNuxtConfig', {
|
788 | enumerable: true,
|
789 | get: function () {
|
790 | return configEdge.loadNuxtConfig;
|
791 | }
|
792 | });
|
793 | exports.Module = ModuleContainer;
|
794 | exports.Nuxt = Nuxt;
|
795 | exports.Resolver = Resolver;
|
796 | exports.loadNuxt = loadNuxt;
|