From 547b8ec2a73f0f16760000f1b7ab54af6bb0e1c2 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Sun, 28 Mar 2021 23:06:51 +0200 Subject: [PATCH] refactor: move utils to kit to be rewritten --- packages/kit/package.json | 6 +++++- packages/kit/src/index.ts | 1 + packages/{nuxt3 => kit}/src/utils/cjs.ts | 0 packages/{nuxt3 => kit}/src/utils/constants.ts | 0 packages/{nuxt3 => kit}/src/utils/context.ts | 0 packages/{nuxt3 => kit}/src/utils/index.ts | 0 packages/{nuxt3 => kit}/src/utils/lang.ts | 0 packages/{nuxt3 => kit}/src/utils/resolve.ts | 0 packages/{nuxt3 => kit}/src/utils/route.ts | 0 packages/{nuxt3 => kit}/src/utils/task.ts | 0 packages/nuxt3/src/builder/builder.ts | 2 +- packages/nuxt3/src/builder/webpack/presets/base.ts | 2 +- packages/nuxt3/src/builder/webpack/presets/style.ts | 2 +- packages/nuxt3/src/builder/webpack/utils/postcss.ts | 2 +- packages/nuxt3/src/builder/webpack/webpack.ts | 2 +- packages/nuxt3/src/core/module.ts | 2 +- packages/nuxt3/src/core/resolver.ts | 4 ++-- 17 files changed, 14 insertions(+), 9 deletions(-) rename packages/{nuxt3 => kit}/src/utils/cjs.ts (100%) rename packages/{nuxt3 => kit}/src/utils/constants.ts (100%) rename packages/{nuxt3 => kit}/src/utils/context.ts (100%) rename packages/{nuxt3 => kit}/src/utils/index.ts (100%) rename packages/{nuxt3 => kit}/src/utils/lang.ts (100%) rename packages/{nuxt3 => kit}/src/utils/resolve.ts (100%) rename packages/{nuxt3 => kit}/src/utils/route.ts (100%) rename packages/{nuxt3 => kit}/src/utils/task.ts (100%) diff --git a/packages/kit/package.json b/packages/kit/package.json index 8a7551289f..08ce10bdf4 100644 --- a/packages/kit/package.json +++ b/packages/kit/package.json @@ -15,10 +15,12 @@ "prepublishOnly": "yarn build && yarn genconfig" }, "dependencies": { + "consola": "^2.15.3", "create-require": "^1.1.1", "defu": "^3.2.2", "dotenv": "^8.2.0", "jiti": "^1.6.4", + "lodash": "^4.17.21", "rc9": "^1.2.0", "scule": "^0.1.1", "std-env": "^2.3.0", @@ -27,7 +29,9 @@ }, "build": { "entries": { - "index": { "format": "cjs" } + "index": { + "format": "cjs" + } } } } diff --git a/packages/kit/src/index.ts b/packages/kit/src/index.ts index 95d535bbc5..62ab80e0b2 100644 --- a/packages/kit/src/index.ts +++ b/packages/kit/src/index.ts @@ -1,2 +1,3 @@ export * from './config/load' export * from './config/env' +export * from './utils' diff --git a/packages/nuxt3/src/utils/cjs.ts b/packages/kit/src/utils/cjs.ts similarity index 100% rename from packages/nuxt3/src/utils/cjs.ts rename to packages/kit/src/utils/cjs.ts diff --git a/packages/nuxt3/src/utils/constants.ts b/packages/kit/src/utils/constants.ts similarity index 100% rename from packages/nuxt3/src/utils/constants.ts rename to packages/kit/src/utils/constants.ts diff --git a/packages/nuxt3/src/utils/context.ts b/packages/kit/src/utils/context.ts similarity index 100% rename from packages/nuxt3/src/utils/context.ts rename to packages/kit/src/utils/context.ts diff --git a/packages/nuxt3/src/utils/index.ts b/packages/kit/src/utils/index.ts similarity index 100% rename from packages/nuxt3/src/utils/index.ts rename to packages/kit/src/utils/index.ts diff --git a/packages/nuxt3/src/utils/lang.ts b/packages/kit/src/utils/lang.ts similarity index 100% rename from packages/nuxt3/src/utils/lang.ts rename to packages/kit/src/utils/lang.ts diff --git a/packages/nuxt3/src/utils/resolve.ts b/packages/kit/src/utils/resolve.ts similarity index 100% rename from packages/nuxt3/src/utils/resolve.ts rename to packages/kit/src/utils/resolve.ts diff --git a/packages/nuxt3/src/utils/route.ts b/packages/kit/src/utils/route.ts similarity index 100% rename from packages/nuxt3/src/utils/route.ts rename to packages/kit/src/utils/route.ts diff --git a/packages/nuxt3/src/utils/task.ts b/packages/kit/src/utils/task.ts similarity index 100% rename from packages/nuxt3/src/utils/task.ts rename to packages/kit/src/utils/task.ts diff --git a/packages/nuxt3/src/builder/builder.ts b/packages/nuxt3/src/builder/builder.ts index fd01f3087b..e44ed8af96 100644 --- a/packages/nuxt3/src/builder/builder.ts +++ b/packages/nuxt3/src/builder/builder.ts @@ -1,8 +1,8 @@ import { join, relative } from 'path' import fsExtra from 'fs-extra' import { debounce } from 'lodash' +import { DeterminedGlobals, determineGlobals } from '@nuxt/kit' import { Nuxt } from '../core' -import { DeterminedGlobals, determineGlobals } from '../utils' import { templateData, compileTemplates, diff --git a/packages/nuxt3/src/builder/webpack/presets/base.ts b/packages/nuxt3/src/builder/webpack/presets/base.ts index d29a15adbf..1a5680d67b 100644 --- a/packages/nuxt3/src/builder/webpack/presets/base.ts +++ b/packages/nuxt3/src/builder/webpack/presets/base.ts @@ -5,7 +5,7 @@ import consola from 'consola' import { DefinePlugin, Configuration } from 'webpack' import FriendlyErrorsWebpackPlugin from '@nuxt/friendly-errors-webpack-plugin' import escapeRegExp from 'lodash/escapeRegExp' -import { isUrl, urlJoin, TARGETS } from '../../../utils' +import { isUrl, urlJoin, TARGETS } from '@nuxt/kit' import WarningIgnorePlugin from '../plugins/warning-ignore' import { WebpackConfigContext, applyPresets, fileName } from '../utils/config' diff --git a/packages/nuxt3/src/builder/webpack/presets/style.ts b/packages/nuxt3/src/builder/webpack/presets/style.ts index 887c6aa846..e562ac568e 100644 --- a/packages/nuxt3/src/builder/webpack/presets/style.ts +++ b/packages/nuxt3/src/builder/webpack/presets/style.ts @@ -1,7 +1,7 @@ import path from 'path' import MiniCssExtractPlugin from 'mini-css-extract-plugin' import CssMinimizerPlugin from 'css-minimizer-webpack-plugin' -import { wrapArray } from '../../../utils' +import { wrapArray } from '@nuxt/kit' import { fileName, WebpackConfigContext, applyPresets } from '../utils/config' export function style (ctx: WebpackConfigContext) { diff --git a/packages/nuxt3/src/builder/webpack/utils/postcss.ts b/packages/nuxt3/src/builder/webpack/utils/postcss.ts index 7fe2957462..9a9ccdb3c4 100644 --- a/packages/nuxt3/src/builder/webpack/utils/postcss.ts +++ b/packages/nuxt3/src/builder/webpack/utils/postcss.ts @@ -6,9 +6,9 @@ import merge from 'lodash/merge' import cloneDeep from 'lodash/cloneDeep' import createResolver from 'postcss-import-resolver' +import { isPureObject } from '@nuxt/kit' import type { Nuxt } from '../../../core' import type { NormalizedConfiguration } from '../../../config' -import { isPureObject } from '../../../utils' export const orderPresets = { cssnanoLast (names) { diff --git a/packages/nuxt3/src/builder/webpack/webpack.ts b/packages/nuxt3/src/builder/webpack/webpack.ts index 992677ce1d..f39f62dd48 100644 --- a/packages/nuxt3/src/builder/webpack/webpack.ts +++ b/packages/nuxt3/src/builder/webpack/webpack.ts @@ -10,8 +10,8 @@ import type { Compiler, Watching } from 'webpack' import type { Context as WebpackDevMiddlewareContext, Options as WebpackDevMiddlewareOptions } from 'webpack-dev-middleware' import type { MiddlewareOptions as WebpackHotMiddlewareOptions } from 'webpack-hot-middleware' +import { TARGETS, parallel, sequence, wrapArray } from '@nuxt/kit' import { Nuxt } from '../../core' -import { TARGETS, parallel, sequence, wrapArray } from '../../utils' import { createMFS } from './utils/mfs' import { client, server } from './configs' import { createWebpackConfigContext, applyPresets, getWebpackConfig } from './utils/config' diff --git a/packages/nuxt3/src/core/module.ts b/packages/nuxt3/src/core/module.ts index 09a2e6c85f..6314c033c7 100644 --- a/packages/nuxt3/src/core/module.ts +++ b/packages/nuxt3/src/core/module.ts @@ -3,7 +3,7 @@ import fs from 'fs' import hash from 'hash-sum' import consola from 'consola' -import { chainFn, sequence } from '../utils' +import { chainFn, sequence } from '@nuxt/kit' import Nuxt from './nuxt' diff --git a/packages/nuxt3/src/core/resolver.ts b/packages/nuxt3/src/core/resolver.ts index 4b36e5ed83..a7888f9f18 100644 --- a/packages/nuxt3/src/core/resolver.ts +++ b/packages/nuxt3/src/core/resolver.ts @@ -2,13 +2,13 @@ import { resolve, join } from 'path' import fs from 'fs-extra' import jiti from 'jiti' -import { Nuxt } from '../core' import { startsWithRootAlias, startsWithSrcAlias, isExternalDependency, clearRequireCache -} from '../utils' +} from '@nuxt/kit' +import { Nuxt } from '../core' interface ResolvePathOptions { isAlias?: boolean