diff --git a/src/compiler/preprocess/decode_sourcemap.ts b/src/compiler/preprocess/decode_sourcemap.ts index fc63c5b9c8..c7e13c2853 100644 --- a/src/compiler/preprocess/decode_sourcemap.ts +++ b/src/compiler/preprocess/decode_sourcemap.ts @@ -1,5 +1,5 @@ import { decode as decode_mappings } from 'sourcemap-codec'; -import { Processed } from '.'; +import { Processed } from './types'; /** * Import decoded sourcemap from mozilla/source-map/SourceMapGenerator diff --git a/src/compiler/preprocess/index.ts b/src/compiler/preprocess/index.ts index 441a64fee8..93b48996c1 100644 --- a/src/compiler/preprocess/index.ts +++ b/src/compiler/preprocess/index.ts @@ -3,39 +3,7 @@ import { getLocator } from 'locate-character'; import { MappedCode, SourceLocation, parse_attached_sourcemap, sourcemap_add_offset, combine_sourcemaps } from '../utils/mapped_code'; import { decode_map } from './decode_sourcemap'; import { replace_in_code, slice_source } from './replace_in_code'; - -import { Location } from 'locate-character'; - -export interface Source { - source: string; - get_location: (search: number) => Location; - file_basename: string; - filename: string; -} - -export interface Processed { - code: string; - map?: string | object; // we are opaque with the type here to avoid dependency on the remapping module for our public types. - dependencies?: string[]; - toString?: () => string; -} - -export type MarkupPreprocessor = (options: { - content: string; - filename: string; -}) => Processed | Promise; - -export type Preprocessor = (options: { - content: string; - attributes: Record; - filename?: string; -}) => Processed | Promise; - -export interface PreprocessorGroup { - markup?: MarkupPreprocessor; - style?: Preprocessor; - script?: Preprocessor; -} +import { MarkupPreprocessor, Source, Preprocessor, PreprocessorGroup, Processed } from './types'; interface SourceUpdate { string?: string; diff --git a/src/compiler/preprocess/replace_in_code.ts b/src/compiler/preprocess/replace_in_code.ts index 450cf05edb..9f49abb0f8 100644 --- a/src/compiler/preprocess/replace_in_code.ts +++ b/src/compiler/preprocess/replace_in_code.ts @@ -1,5 +1,5 @@ import { MappedCode } from '../utils/mapped_code'; -import { Source } from '.'; +import { Source } from './types'; interface Replacement { offset: number; diff --git a/src/compiler/preprocess/types.ts b/src/compiler/preprocess/types.ts new file mode 100644 index 0000000000..06890ad7b5 --- /dev/null +++ b/src/compiler/preprocess/types.ts @@ -0,0 +1,32 @@ +import { Location } from 'locate-character'; + +export interface Source { + source: string; + get_location: (search: number) => Location; + file_basename: string; + filename: string; +} + +export interface Processed { + code: string; + map?: string | object; // we are opaque with the type here to avoid dependency on the remapping module for our public types. + dependencies?: string[]; + toString?: () => string; +} + +export type MarkupPreprocessor = (options: { + content: string; + filename: string; +}) => Processed | Promise; + +export type Preprocessor = (options: { + content: string; + attributes: Record; + filename?: string; +}) => Processed | Promise; + +export interface PreprocessorGroup { + markup?: MarkupPreprocessor; + style?: Preprocessor; + script?: Preprocessor; +} diff --git a/src/compiler/utils/mapped_code.ts b/src/compiler/utils/mapped_code.ts index deda0f1e0b..d0cab9f49f 100644 --- a/src/compiler/utils/mapped_code.ts +++ b/src/compiler/utils/mapped_code.ts @@ -1,7 +1,7 @@ import { DecodedSourceMap, RawSourceMap, SourceMapLoader } from '@ampproject/remapping/dist/types/types'; import remapping from '@ampproject/remapping'; import { SourceMap } from 'magic-string'; -import { Source, Processed } from '../preprocess'; +import { Source, Processed } from '../preprocess/types'; export type SourceLocation = { line: number;