Skip to content

Commit

Permalink
feat: @vitjs/utils
Browse files Browse the repository at this point in the history
  • Loading branch information
yunsii committed Jan 10, 2022
1 parent 326d5a7 commit 508fc90
Show file tree
Hide file tree
Showing 12 changed files with 63 additions and 171 deletions.
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
"access": "public"
},
"dependencies": {
"@umijs/utils": "^3.5.20",
"lodash": "^4.17.21",
"mkdirp": "^1.0.4"
},
"devDependencies": {
"@types/lodash": "^4.14.168",
"@types/mkdirp": "^1.0.1"
"@types/mkdirp": "^1.0.1",
"@vitjs/utils": "^0.6.4"
},
"gitHead": "3a9f3aab27ee09337490e3d7b3b5bfd2d81683a4"
}
2 changes: 1 addition & 1 deletion packages/core/src/Route/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { resolve } from 'path';
import { winPath } from '@umijs/utils';
import _cloneDeep from 'lodash/cloneDeep';
import _uniq from 'lodash/uniq';
import { winPath } from '@vitjs/utils';

import Service from '../Service';

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/Service/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { EOL } from 'os';
import { existsSync, readFileSync, writeFileSync } from 'fs';
import { resolve, join, dirname, relative } from 'path';
import mkdirp from 'mkdirp';
import { winPath } from '@umijs/utils';
import { winPath } from '@vitjs/utils';

import Route, { RouteOptions } from '../Route';
import { isTSFile, getGlobalFiles } from './utils';
Expand Down
1 change: 1 addition & 0 deletions packages/utils/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# @vitjs/utils
31 changes: 31 additions & 0 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "@vitjs/utils",
"version": "0.6.4",
"description": "@vitjs/utils",
"keywords": [
"vit"
],
"author": "theprimone <yuns.xie@qq.com>",
"homepage": "https://github.com/vitjs/vit#readme",
"license": "MIT",
"main": "dist/index.js",
"files": [
"dist",
"package.json",
"README.md"
],
"scripts": {
"build": "rm -rf ./dist && tsc",
"dev": "rm -rf ./dist && tsc -w"
},
"repository": {
"type": "git",
"url": "git+https://github.com/vitjs/vit.git"
},
"bugs": {
"url": "https://github.com/vitjs/vit/issues"
},
"publishConfig": {
"access": "public"
}
}
1 change: 1 addition & 0 deletions packages/utils/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as winPath } from './winPath/winPath';
10 changes: 10 additions & 0 deletions packages/utils/src/winPath/winPath.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// ref: https://github.com/umijs/umi/blob/master/packages/utils/src/winPath/winPath.ts

export default function (path: string) {
const isExtendedLengthPath = /^\\\\\?\\/.test(path);
if (isExtendedLengthPath) {
return path;
}

return path.replace(/\\/g, '/');
}
9 changes: 9 additions & 0 deletions packages/utils/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./dist",
"target": "es2018",
"module": "commonjs",
"lib": ["es2018"]
}
}
2 changes: 1 addition & 1 deletion packages/vit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
},
"dependencies": {
"@ant-design/icons": "^4.6.2",
"@umijs/utils": "^3.5.20",
"@vitjs/core": "^0.6.4",
"@vitjs/utils": "^0.6.4",
"chokidar": "^3.5.1",
"globby": "^11.0.3",
"lodash": "^4.17.21",
Expand Down
2 changes: 1 addition & 1 deletion packages/vit/src/generateFiles/routes.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { readFileSync } from 'fs';
import { resolve } from 'path';
import Mustache from 'mustache';
import { winPath } from '@umijs/utils';
import { Service } from '@vitjs/core';
import { winPath } from '@vitjs/utils';

import { resolveIcons } from './utils';

Expand Down
2 changes: 1 addition & 1 deletion packages/vit/src/vitApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { resolve } from 'path';
import type { Plugin, ResolvedConfig } from 'vite';
import { Service } from '@vitjs/core';
import chokidar, { FSWatcher } from 'chokidar';
import { winPath } from '@umijs/utils';
import { winPath } from '@vitjs/utils';

import { exportStatic } from './preset';
import { generateHistory, generateRoutes, generateVit, generateExports } from './generateFiles';
Expand Down
Loading

0 comments on commit 508fc90

Please sign in to comment.