Repository: nuxt/nuxt.js
Pull request #7399 (2020-05-20 15:33:58)

refactor(config): alias `export` to `generate`
<!--- Provide a general summary of your changes in the title above -->

## Types of changes
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
- [ ] Bug fix (a non-breaking change which fixes an issue)
- [ ] New feature (a non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)


## Description
<!--- Describe your changes in detail -->
<!--- Why is this change required? What problem does it solve? -->
<!--- If it resolves an open issue, please link to the issue here. For example "Resolves: #1337" -->
As of the new `nuxt export` command, it makes sense using `export` in `nuxt.config`. This alias is a backport from Nuxt3. After defaults getting applied, we keep the same references so any modifications to each, update another one

## Checklist:
<!--- Put an `x` in all the boxes that apply. -->
<!--- If your change requires a documentation PR, please link it appropriately -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly. (PR: #)
- [ ] I have added tests to cover my changes (if not applicable, please state why)
- [ ] All new and existing tests are passing.



codecov-commenter: # [Codecov](https://codecov.io/gh/nuxt/nuxt.js/pull/7399?src=pr&el=h1) Report
> Merging [#7399](https://codecov.io/gh/nuxt/nuxt.js/pull/7399?src=pr&el=desc) into [dev](https://codecov.io/gh/nuxt/nuxt.js/commit/e9a4ca6ac2a6ba7a0b91470bc270e93162654a3c&el=desc) will **increase** coverage by `0.02%`.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/nuxt/nuxt.js/pull/7399/graphs/tree.svg?width=650&height=150&src=pr&token=nGD1PtMB3M)](https://codecov.io/gh/nuxt/nuxt.js/pull/7399?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##              dev    #7399      +/-   ##
==========================================
+ Coverage   70.19%   70.21%   +0.02%     
==========================================
  Files          88       88              
  Lines        3670     3673       +3     
  Branches     1000     1001       +1     
==========================================
+ Hits         2576     2579       +3     
  Misses        887      887              
  Partials      207      207              
```

| Flag | Coverage Δ | |
|---|---|---|
| #unittests | `70.21% <100.00%> (+0.02%)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/nuxt/nuxt.js/pull/7399?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [packages/config/src/options.js](https://codecov.io/gh/nuxt/nuxt.js/pull/7399/diff?src=pr&el=tree#diff-cGFja2FnZXMvY29uZmlnL3NyYy9vcHRpb25zLmpz) | `97.66% <100.00%> (+0.03%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/nuxt/nuxt.js/pull/7399?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/nuxt/nuxt.js/pull/7399?src=pr&el=footer). Last update [e9a4ca6...883cc02](https://codecov.io/gh/nuxt/nuxt.js/pull/7399?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/packages/config/src/options.js b/packages/config/src/options.js
index 553de8939..b4baa0dd0 100644
--- a/packages/config/src/options.js
+++ b/packages/config/src/options.js
@@ -114,6 +114,13 @@ export function getNuxtConfig (_options) {
     options.router.base += '/'
   }
 
+  // Alias export to generate
+  // TODO: switch to export by default for nuxt3
+  if (options.export) {
+    options.generate = defu(options.export, options.generate)
+  }
+  exports.export = options.generate
+
   // Check srcDir and generate.dir existence
   const hasSrcDir = isNonEmptyString(options.srcDir)
   const hasGenerateDir = isNonEmptyString(options.generate.dir)


Test patch:
diff --git a/packages/config/test/options.test.js b/packages/config/test/options.test.js
index ba5a7d99d..7bfb9ccad 100644
--- a/packages/config/test/options.test.js
+++ b/packages/config/test/options.test.js
@@ -162,6 +162,11 @@ describe('config: options', () => {
     expect(fallback).toEqual('fallback.html')
   })
 
+  test('export should alias to generate', () => {
+    const { generate: { fallback } } = getNuxtConfig({ export: { fallback: 'fallback.html' } })
+    expect(fallback).toEqual('fallback.html')
+  })
+
   test('should disable parallel if extractCSS is enabled', () => {
     const { build: { parallel } } = getNuxtConfig({ build: { extractCSS: true, parallel: true } })
     expect(parallel).toEqual(false)