Skip to content

Commit 66d0529

Browse files
committed
optimize build output
1 parent 12cff4d commit 66d0529

12 files changed

+60
-58
lines changed

src/tokenTypes.js

+19-17
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,22 @@ export const regExpToken = (regExp, transform = String) => node => {
5454
return value
5555
}
5656

57-
export const tokens = {
58-
SPACE: noopToken(node => node.type === 'space'),
59-
SLASH: noopToken(node => node.type === 'div' && node.value === '/'),
60-
COMMA: noopToken(node => node.type === 'div' && node.value === ','),
61-
WORD: valueForTypeToken('word'),
62-
NONE: regExpToken(noneRe),
63-
AUTO: regExpToken(autoRe),
64-
NUMBER: regExpToken(numberRe, Number),
65-
LENGTH: regExpToken(lengthRe, Number),
66-
UNSUPPORTED_LENGTH_UNIT: regExpToken(unsupportedUnitRe),
67-
ANGLE: regExpToken(angleRe),
68-
PERCENT: regExpToken(percentRe),
69-
IDENT: regExpToken(identRe),
70-
STRING: matchString,
71-
COLOR: matchColor,
72-
LINE: regExpToken(/^(none|underline|line-through)$/i),
73-
}
57+
export const SPACE = noopToken(node => node.type === 'space')
58+
export const SLASH = noopToken(
59+
node => node.type === 'div' && node.value === '/'
60+
)
61+
export const COMMA = noopToken(
62+
node => node.type === 'div' && node.value === ','
63+
)
64+
export const WORD = valueForTypeToken('word')
65+
export const NONE = regExpToken(noneRe)
66+
export const AUTO = regExpToken(autoRe)
67+
export const NUMBER = regExpToken(numberRe, Number)
68+
export const LENGTH = regExpToken(lengthRe, Number)
69+
export const UNSUPPORTED_LENGTH_UNIT = regExpToken(unsupportedUnitRe)
70+
export const ANGLE = regExpToken(angleRe)
71+
export const PERCENT = regExpToken(percentRe)
72+
export const IDENT = regExpToken(identRe)
73+
export const STRING = matchString
74+
export const COLOR = matchColor
75+
export const LINE = regExpToken(/^(none|underline|line-through)$/i)

src/transforms/border.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
import { regExpToken, tokens } from '../tokenTypes'
2-
3-
const { NONE, COLOR, LENGTH, UNSUPPORTED_LENGTH_UNIT, SPACE } = tokens
1+
import {
2+
regExpToken,
3+
NONE,
4+
COLOR,
5+
LENGTH,
6+
UNSUPPORTED_LENGTH_UNIT,
7+
SPACE,
8+
} from '../tokenTypes'
49

510
const BORDER_STYLE = regExpToken(/^(solid|dashed|dotted)$/)
611

src/transforms/flex.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
import { tokens } from '../tokenTypes'
2-
3-
const {
1+
import {
42
NONE,
53
AUTO,
64
NUMBER,
75
LENGTH,
86
UNSUPPORTED_LENGTH_UNIT,
97
PERCENT,
108
SPACE,
11-
} = tokens
9+
} from '../tokenTypes'
1210

1311
const defaultFlexGrow = 1
1412
const defaultFlexShrink = 1

src/transforms/flexFlow.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import { regExpToken, tokens } from '../tokenTypes'
2-
3-
const { SPACE } = tokens
1+
import { regExpToken, SPACE } from '../tokenTypes'
42

53
const FLEX_WRAP = regExpToken(/(nowrap|wrap|wrap-reverse)/)
64
const FLEX_DIRECTION = regExpToken(/(row|row-reverse|column|column-reverse)/)

src/transforms/font.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import parseFontFamily from './fontFamily'
2-
import { regExpToken, tokens } from '../tokenTypes'
2+
import {
3+
regExpToken,
4+
SPACE,
5+
LENGTH,
6+
UNSUPPORTED_LENGTH_UNIT,
7+
NUMBER,
8+
SLASH,
9+
} from '../tokenTypes'
310

4-
const { SPACE, LENGTH, UNSUPPORTED_LENGTH_UNIT, NUMBER, SLASH } = tokens
511
const NORMAL = regExpToken(/^(normal)$/)
612
const STYLE = regExpToken(/^(italic)$/)
713
const WEIGHT = regExpToken(/^([1-9]00|bold)$/)

src/transforms/fontFamily.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import { tokens } from '../tokenTypes'
2-
3-
const { SPACE, IDENT, STRING } = tokens
1+
import { SPACE, IDENT, STRING } from '../tokenTypes'
42

53
export default tokenStream => {
64
let fontFamily

src/transforms/index.js

+9-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { tokens } from '../tokenTypes'
1+
import {
2+
IDENT,
3+
WORD,
4+
COLOR,
5+
LENGTH,
6+
UNSUPPORTED_LENGTH_UNIT,
7+
PERCENT,
8+
AUTO,
9+
} from '../tokenTypes'
210
import border from './border'
311
import boxShadow from './boxShadow'
412
import flex from './flex'
@@ -12,16 +20,6 @@ import textShadow from './textShadow'
1220
import transform from './transform'
1321
import { directionFactory, parseShadowOffset } from './util'
1422

15-
const {
16-
IDENT,
17-
WORD,
18-
COLOR,
19-
LENGTH,
20-
UNSUPPORTED_LENGTH_UNIT,
21-
PERCENT,
22-
AUTO,
23-
} = tokens
24-
2523
const background = tokenStream => ({
2624
backgroundColor: tokenStream.expect(COLOR),
2725
})

src/transforms/placeContent.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import { regExpToken, tokens } from '../tokenTypes'
2-
3-
const { SPACE } = tokens
1+
import { regExpToken, SPACE } from '../tokenTypes'
42

53
const ALIGN_CONTENT = regExpToken(
64
/(flex-(?:start|end)|center|stretch|space-(?:between|around))/

src/transforms/textDecoration.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import { regExpToken, tokens } from '../tokenTypes'
2-
3-
const { SPACE, LINE, COLOR } = tokens
1+
import { regExpToken, SPACE, LINE, COLOR } from '../tokenTypes'
42

53
const STYLE = regExpToken(/^(solid|double|dotted|dashed)$/)
64

src/transforms/textDecorationLine.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import { tokens } from '../tokenTypes'
2-
3-
const { SPACE, LINE } = tokens
1+
import { SPACE, LINE } from '../tokenTypes'
42

53
export default tokenStream => {
64
const lines = []

src/transforms/transform.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import { tokens } from '../tokenTypes'
2-
3-
const { SPACE, COMMA, LENGTH, NUMBER, ANGLE } = tokens
1+
import { SPACE, COMMA, LENGTH, NUMBER, ANGLE } from '../tokenTypes'
42

53
const oneOfType = tokenType => functionStream => {
64
const value = functionStream.expect(tokenType)

src/transforms/util.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
import { tokens } from '../tokenTypes'
2-
3-
const { LENGTH, UNSUPPORTED_LENGTH_UNIT, PERCENT, COLOR, SPACE, NONE } = tokens
1+
import {
2+
LENGTH,
3+
UNSUPPORTED_LENGTH_UNIT,
4+
PERCENT,
5+
COLOR,
6+
SPACE,
7+
NONE,
8+
} from '../tokenTypes'
49

510
export const directionFactory = ({
611
types = [LENGTH, UNSUPPORTED_LENGTH_UNIT, PERCENT],

0 commit comments

Comments
 (0)