From 007ca051743f68d0655ae8669dd62dfe5e95df00 Mon Sep 17 00:00:00 2001 From: Jonas Galvez Date: Sat, 27 Oct 2018 17:27:16 -0300 Subject: [PATCH] refactor: move config files to @nuxt/config (#4212) --- packages/cli/src/utils.js | 2 +- packages/cli/test/unit/utils.test.js | 2 +- packages/common/package.json | 3 +-- packages/common/src/index.js | 3 --- packages/common/src/nuxt.config.js | 3 --- packages/common/src/options.js | 5 ++--- packages/config/package.js | 3 +++ packages/config/package.json | 18 ++++++++++++++++++ .../{common => config}/src/config/build.js | 0 .../{common => config}/src/config/index.js | 0 .../{common => config}/src/config/messages.js | 0 .../{common => config}/src/config/render.js | 0 .../{common => config}/src/config/router.js | 0 .../{common => config}/src/config/server.js | 0 packages/config/src/index.js | 11 +++++++++++ packages/{common => config}/src/modes.js | 0 packages/core/src/renderer.js | 3 ++- 17 files changed, 39 insertions(+), 14 deletions(-) delete mode 100644 packages/common/src/nuxt.config.js create mode 100644 packages/config/package.js create mode 100644 packages/config/package.json rename packages/{common => config}/src/config/build.js (100%) rename packages/{common => config}/src/config/index.js (100%) rename packages/{common => config}/src/config/messages.js (100%) rename packages/{common => config}/src/config/render.js (100%) rename packages/{common => config}/src/config/router.js (100%) rename packages/{common => config}/src/config/server.js (100%) create mode 100644 packages/config/src/index.js rename packages/{common => config}/src/modes.js (100%) diff --git a/packages/cli/src/utils.js b/packages/cli/src/utils.js index 8a8b6a6ce7..5810e4d792 100644 --- a/packages/cli/src/utils.js +++ b/packages/cli/src/utils.js @@ -4,7 +4,7 @@ import consola from 'consola' import esm from 'esm' import wrapAnsi from 'wrap-ansi' import defaultsDeep from 'lodash/defaultsDeep' -import { nuxtServerConfig } from '@nuxt/common' +import { server as nuxtServerConfig } from '@nuxt/config' const _require = esm(module, { cache: false, diff --git a/packages/cli/test/unit/utils.test.js b/packages/cli/test/unit/utils.test.js index 443cab528c..e7a5cd50e1 100644 --- a/packages/cli/test/unit/utils.test.js +++ b/packages/cli/test/unit/utils.test.js @@ -1,4 +1,4 @@ -import { nuxtServerConfig } from '@nuxt/common' +import { server as nuxtServerConfig } from '@nuxt/config' import { consola } from '../utils' import * as utils from '../../src/utils' diff --git a/packages/common/package.json b/packages/common/package.json index bb4d1428d7..28440995fc 100644 --- a/packages/common/package.json +++ b/packages/common/package.json @@ -9,8 +9,7 @@ "main": "dist/common.js", "dependencies": { "consola": "^1.4.4", - "lodash": "^4.17.11", - "std-env": "^2.0.2" + "lodash": "^4.17.11" }, "publishConfig": { "access": "public" diff --git a/packages/common/src/index.js b/packages/common/src/index.js index ce636223c6..67718e1adf 100644 --- a/packages/common/src/index.js +++ b/packages/common/src/index.js @@ -1,6 +1,3 @@ -export { default as Modes } from './modes' -export { default as NuxtConfig } from './nuxt.config' -export { default as nuxtServerConfig } from './config/server' export { default as Options } from './options' export { default as BuildContext } from './build/context' export * from './utils' diff --git a/packages/common/src/nuxt.config.js b/packages/common/src/nuxt.config.js deleted file mode 100644 index 657adb95f7..0000000000 --- a/packages/common/src/nuxt.config.js +++ /dev/null @@ -1,3 +0,0 @@ -import config from './config' - -export default config diff --git a/packages/common/src/options.js b/packages/common/src/options.js index 7d674cdfec..d6e918303e 100644 --- a/packages/common/src/options.js +++ b/packages/common/src/options.js @@ -5,10 +5,9 @@ import defaults from 'lodash/defaults' import pick from 'lodash/pick' import isObject from 'lodash/isObject' import consola from 'consola' - +// eslint-disable-next-line +import { default as NuxtConfig, Modes } from '@nuxt/config' import { isPureObject, isUrl, guardDir, isString } from './utils' -import Modes from './modes' -import NuxtConfig from './nuxt.config' // hasValue utility const hasValue = v => typeof v === 'string' && v diff --git a/packages/config/package.js b/packages/config/package.js new file mode 100644 index 0000000000..19d0ef6e2d --- /dev/null +++ b/packages/config/package.js @@ -0,0 +1,3 @@ +export default { + build: true +} diff --git a/packages/config/package.json b/packages/config/package.json new file mode 100644 index 0000000000..045596e9ef --- /dev/null +++ b/packages/config/package.json @@ -0,0 +1,18 @@ +{ + "name": "@nuxt/config", + "version": "2.2.0", + "repository": "nuxt/nuxt.js", + "license": "MIT", + "files": [ + "dist" + ], + "main": "dist/config.js", + "dependencies": { + "consola": "^1.4.4", + "lodash": "^4.17.11", + "std-env": "^2.0.2" + }, + "publishConfig": { + "access": "public" + } +} diff --git a/packages/common/src/config/build.js b/packages/config/src/config/build.js similarity index 100% rename from packages/common/src/config/build.js rename to packages/config/src/config/build.js diff --git a/packages/common/src/config/index.js b/packages/config/src/config/index.js similarity index 100% rename from packages/common/src/config/index.js rename to packages/config/src/config/index.js diff --git a/packages/common/src/config/messages.js b/packages/config/src/config/messages.js similarity index 100% rename from packages/common/src/config/messages.js rename to packages/config/src/config/messages.js diff --git a/packages/common/src/config/render.js b/packages/config/src/config/render.js similarity index 100% rename from packages/common/src/config/render.js rename to packages/config/src/config/render.js diff --git a/packages/common/src/config/router.js b/packages/config/src/config/router.js similarity index 100% rename from packages/common/src/config/router.js rename to packages/config/src/config/router.js diff --git a/packages/common/src/config/server.js b/packages/config/src/config/server.js similarity index 100% rename from packages/common/src/config/server.js rename to packages/config/src/config/server.js diff --git a/packages/config/src/index.js b/packages/config/src/index.js new file mode 100644 index 0000000000..e8406c6ab3 --- /dev/null +++ b/packages/config/src/index.js @@ -0,0 +1,11 @@ +import NuxtConfig from './config' + +// Export individual bundles for easier access +export { default as Modes } from './modes' +export { default as build } from './config/build' +export { default as messages } from './config/messages' +export { default as render } from './config/render' +export { default as router } from './config/router' +export { default as server } from './config/server' + +export default NuxtConfig diff --git a/packages/common/src/modes.js b/packages/config/src/modes.js similarity index 100% rename from packages/common/src/modes.js rename to packages/config/src/modes.js diff --git a/packages/core/src/renderer.js b/packages/core/src/renderer.js index 33348b7aba..c783ac7885 100644 --- a/packages/core/src/renderer.js +++ b/packages/core/src/renderer.js @@ -9,7 +9,8 @@ import connect from 'connect' import launchMiddleware from 'launch-editor-middleware' import consola from 'consola' -import { NuxtConfig, isUrl, timeout, waitFor, determineGlobals } from '@nuxt/common' +import { isUrl, timeout, waitFor, determineGlobals } from '@nuxt/common' +import NuxtConfig from '@nuxt/config' import MetaRenderer from './meta' import errorMiddleware from './middleware/error'