Skip to content

Commit

Permalink
refactor(compiler-sfc): move related files into separate directories
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Apr 5, 2023
1 parent 869f3fb commit b2c874e
Show file tree
Hide file tree
Showing 16 changed files with 20 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
createAssetUrlTransformWithOptions,
AssetURLOptions,
normalizeOptions
} from '../src/templateTransformAssetUrl'
} from '../src/template/transformAssetUrl'
import { transformElement } from '../../compiler-core/src/transforms/transformElement'
import { transformBind } from '../../compiler-core/src/transforms/vBind'
import { stringifyStatic } from '../../compiler-dom/src/transforms/stringifyStatic'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import {
import {
transformSrcset,
createSrcsetTransformWithOptions
} from '../src/templateTransformSrcset'
} from '../src/template/transformSrcset'
import { transformElement } from '../../compiler-core/src/transforms/transformElement'
import { transformBind } from '../../compiler-core/src/transforms/vBind'
import {
AssetURLOptions,
normalizeOptions
} from '../src/templateTransformAssetUrl'
} from '../src/template/transformAssetUrl'
import { stringifyStatic } from '../../compiler-dom/src/transforms/stringifyStatic'

function compileWithSrcset(
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler-sfc/__tests__/templateUtils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
isRelativeUrl,
isExternalUrl,
isDataUrl
} from '../../compiler-sfc/src/templateUtils'
} from '../src/template/templateUtils'

describe('compiler sfc:templateUtils isRelativeUrl', () => {
test('should return true when The first character of the string path is .', () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/compiler-sfc/src/compileScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ import {
CSS_VARS_HELPER,
genCssVarsCode,
genNormalScriptCssVarsCode
} from './cssVars'
} from './style/cssVars'
import { compileTemplate, SFCTemplateCompileOptions } from './compileTemplate'
import { warnOnce } from './warn'
import { rewriteDefaultAST } from './rewriteDefault'
import { createCache } from './cache'
import { shouldTransform, transformAST } from '@vue/reactivity-transform'
import { transformDestructuredProps } from './compileScriptPropsDestructure'
import { transformDestructuredProps } from './script/propsDestructure'

// Special compiler macros
const DEFINE_PROPS = 'defineProps'
Expand Down
8 changes: 4 additions & 4 deletions packages/compiler-sfc/src/compileStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ import postcss, {
Message,
LazyResult
} from 'postcss'
import trimPlugin from './stylePluginTrim'
import scopedPlugin from './stylePluginScoped'
import trimPlugin from './style/pluginTrim'
import scopedPlugin from './style/pluginScoped'
import {
processors,
StylePreprocessor,
StylePreprocessorResults,
PreprocessLang
} from './stylePreprocessors'
} from './style/preprocessors'
import { RawSourceMap } from 'source-map'
import { cssVarsPlugin } from './cssVars'
import { cssVarsPlugin } from './style/cssVars'
import postcssModules from 'postcss-modules'

export interface SFCStyleCompileOptions {
Expand Down
6 changes: 3 additions & 3 deletions packages/compiler-sfc/src/compileTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ import {
createAssetUrlTransformWithOptions,
AssetURLTagConfig,
normalizeOptions
} from './templateTransformAssetUrl'
} from './template/transformAssetUrl'
import {
transformSrcset,
createSrcsetTransformWithOptions
} from './templateTransformSrcset'
} from './template/transformSrcset'
import { generateCodeFrame, isObject } from '@vue/shared'
import * as CompilerDOM from '@vue/compiler-dom'
import * as CompilerSSR from '@vue/compiler-ssr'
import consolidate from '@vue/consolidate'
import { warnOnce } from './warn'
import { genCssVarsFromList } from './cssVars'
import { genCssVarsFromList } from './style/cssVars'

export interface TemplateCompiler {
compile(template: string, options: CompilerOptions): CodegenResult
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler-sfc/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export type { SFCScriptCompileOptions } from './compileScript'
export type {
AssetURLOptions,
AssetURLTagConfig
} from './templateTransformAssetUrl'
} from './template/transformAssetUrl'
export type {
CompilerOptions,
CompilerError,
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler-sfc/src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import * as CompilerDOM from '@vue/compiler-dom'
import { RawSourceMap, SourceMapGenerator } from 'source-map'
import { TemplateCompiler } from './compileTemplate'
import { parseCssVars } from './cssVars'
import { parseCssVars } from './style/cssVars'
import { createCache } from './cache'
import { hmrShouldReload, ImportBinding } from './compileScript'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
unwrapTSNode
} from '@vue/compiler-core'
import { genPropsAccessExp } from '@vue/shared'
import { PropsDestructureBindings } from './compileScript'
import { PropsDestructureBindings } from '../compileScript'

/**
* true -> prop binding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
SimpleExpressionNode,
BindingMetadata
} from '@vue/compiler-dom'
import { SFCDescriptor } from './parse'
import { SFCDescriptor } from '../parse'
import { PluginCreator } from 'postcss'
import hash from 'hash-sum'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PluginCreator, Rule, AtRule } from 'postcss'
import selectorParser from 'postcss-selector-parser'
import { warn } from './warn'
import { warn } from '../warn'

const animationNameRE = /^(-\w+-)?animation-name$/
const animationRE = /^(-\w+-)?animation$/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import merge from 'merge-source-map'
import { RawSourceMap } from 'source-map'
import { SFCStyleCompileOptions } from './compileStyle'
import { SFCStyleCompileOptions } from '../compileStyle'
import { isFunction } from '@vue/shared'

export type StylePreprocessor = (
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ import {
isExternalUrl,
isDataUrl
} from './templateUtils'
import {
AssetURLOptions,
defaultAssetUrlOptions
} from './templateTransformAssetUrl'
import { AssetURLOptions, defaultAssetUrlOptions } from './transformAssetUrl'

const srcsetTags = ['img', 'source']

Expand Down

0 comments on commit b2c874e

Please sign in to comment.