Skip to content

Commit 062b66e

Browse files
committed
fix: remove circular dependencies in utils
1 parent 63d3841 commit 062b66e

File tree

7 files changed

+42
-46
lines changed

7 files changed

+42
-46
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"@babel/core": "^7.5.5",
3838
"@babel/parser": "^7.5.5",
3939
"babel-loader": "^8.0.6",
40+
"glob": "^7.1.4",
4041
"hable": "^1.0.1",
4142
"signal-exit": "^3.0.2",
4243
"tree-kill": "^1.2.1",
@@ -66,7 +67,6 @@
6667
"eslint-plugin-vue": "^5.2.3",
6768
"finalhandler": "^1.1.2",
6869
"geckodriver": "^1.16.2",
69-
"glob": "^7.1.4",
7070
"jest": "^24.8.0",
7171
"jsdom": "^15.1.1",
7272
"lodash.defaultsdeep": "^4.6.1",

scripts/rollup.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function rollupConfig({
3838
].concat(plugins),
3939
})
4040
}
41-
41+
console.log(rollupConfig())
4242
export default [
4343
rollupConfig()
4444
]

src/utils/cache.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import path from 'path'
2-
import { md5sum, findNodeModulesPath } from '.'
2+
import { md5sum } from './hash'
3+
import { findNodeModulesPath } from './package'
34

45
export function createCacheKey(fn, opts) {
56
if (typeof opts !== 'string') {

src/utils/index.js

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,11 @@
1-
import { BrowserError } from './errors'
2-
31
export * from './browser'
42
export * from './compiler'
53
export * from './cache'
64
export * from './errors'
75
export * from './fs'
86
export * from './hash'
7+
export * from './misc'
98
export * from './package'
109
export * from './page-functions'
1110
export * from './parser'
1211
export * from './timers'
13-
14-
export const camelCase = str => str.replace(/(^|[-_.\s]+)(.)/g, (m, $1, $2, offset) => !offset ? $2.toLowerCase() : $2.toUpperCase())
15-
16-
export function abstractGuard(className, { name } = {}) {
17-
if (className === name) {
18-
throw new BrowserError(`Do not use abstract class '${className}' directly`)
19-
}
20-
}
21-
22-
export function isMockedFunction(fn, fnName) {
23-
return fn.name !== fnName
24-
}
25-
26-
export async function loadDependency(dependency) {
27-
try {
28-
const module = await import(dependency).then(m => m.default || m)
29-
return module
30-
} catch (e) {
31-
throw new BrowserError(`Could not import the required dependency '${dependency}'
32-
(error: ${e.message})
33-
34-
Please install the dependency with:
35-
$ npm install ${dependency}
36-
or
37-
$ yarn add ${dependency}
38-
`)
39-
}
40-
}
41-
42-
export const waitFor = time => new Promise(resolve => setTimeout(resolve, time || 1000))

src/utils/misc.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { BrowserError } from './errors'
2+
3+
export const camelCase = str => str.replace(/(^|[-_.\s]+)(.)/g, (m, $1, $2, offset) => !offset ? $2.toLowerCase() : $2.toUpperCase())
4+
5+
export function abstractGuard(className, { name } = {}) {
6+
if (className === name) {
7+
throw new BrowserError(`Do not use abstract class '${className}' directly`)
8+
}
9+
}
10+
11+
export function isMockedFunction(fn, fnName) {
12+
return fn.name !== fnName
13+
}
14+
15+
export async function loadDependency(dependency) {
16+
try {
17+
const module = await import(dependency).then(m => m.default || m)
18+
return module
19+
} catch (e) {
20+
throw new BrowserError(`Could not import the required dependency '${dependency}'
21+
(error: ${e.message})
22+
23+
Please install the dependency with:
24+
$ npm install ${dependency}
25+
or
26+
$ yarn add ${dependency}
27+
`)
28+
}
29+
}
30+
31+
export const waitFor = time => new Promise(resolve => setTimeout(resolve, time || 1000))

src/utils/page-functions.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
import path from 'path'
22
import webpack from 'webpack'
3-
import {
4-
readFile,
5-
exists,
6-
stats,
7-
glob,
8-
camelCase,
9-
findNodeModulesPath,
10-
createCacheKey,
11-
getCachePath
12-
} from '.'
3+
import { readFile, exists, stats, glob } from './fs'
4+
import { getCachePath, createCacheKey } from './cache'
5+
import { camelCase } from './misc'
6+
import { findNodeModulesPath } from './package'
137

148
export async function createPageFunctions(page, sourceFiles, babelPresets) {
159
const pageFunctions = {}

src/utils/parser.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { types, transformFromAstSync } from '@babel/core'
22
import { parseExpression } from '@babel/parser'
3-
import { BrowserError, createCacheKey } from '.'
3+
import { BrowserError } from './errors'
4+
import { createCacheKey } from './cache'
45

56
const fnCache = {}
67

0 commit comments

Comments
 (0)