From 94c271c4334bc124d291fa23da6dc2c302e558e3 Mon Sep 17 00:00:00 2001 From: Luke Edwards Date: Fri, 19 Mar 2021 12:27:33 -0700 Subject: [PATCH 1/3] fix: revert breaking change for `compiler/preprocess` types location Reverts the change in `interface` locations in abf11bb02b2afbd3e4cac509a0f70e318c306364 No functionality changes. --- src/compiler/preprocess/decode_sourcemap.ts | 2 +- src/compiler/preprocess/index.ts | 34 ++++++++++++++++++++- src/compiler/preprocess/replace_in_code.ts | 2 +- src/compiler/preprocess/types.ts | 32 ------------------- src/compiler/utils/mapped_code.ts | 2 +- 5 files changed, 36 insertions(+), 36 deletions(-) delete mode 100644 src/compiler/preprocess/types.ts diff --git a/src/compiler/preprocess/decode_sourcemap.ts b/src/compiler/preprocess/decode_sourcemap.ts index c7e13c28537f..fc63c5b9c853 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 './types'; +import { Processed } from '.'; /** * Import decoded sourcemap from mozilla/source-map/SourceMapGenerator diff --git a/src/compiler/preprocess/index.ts b/src/compiler/preprocess/index.ts index 93b48996c186..441a64fee8ef 100644 --- a/src/compiler/preprocess/index.ts +++ b/src/compiler/preprocess/index.ts @@ -3,7 +3,39 @@ 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 { MarkupPreprocessor, Source, Preprocessor, PreprocessorGroup, Processed } from './types'; + +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; +} interface SourceUpdate { string?: string; diff --git a/src/compiler/preprocess/replace_in_code.ts b/src/compiler/preprocess/replace_in_code.ts index 9f49abb0f86e..450cf05edb57 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 './types'; +import { Source } from '.'; interface Replacement { offset: number; diff --git a/src/compiler/preprocess/types.ts b/src/compiler/preprocess/types.ts deleted file mode 100644 index 06890ad7b5ca..000000000000 --- a/src/compiler/preprocess/types.ts +++ /dev/null @@ -1,32 +0,0 @@ -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 d0cab9f49fbf..deda0f1e0be4 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/types'; +import { Source, Processed } from '../preprocess'; export type SourceLocation = { line: number; From 60976e56a70087aa0948340a830f46b47618a409 Mon Sep 17 00:00:00 2001 From: Luke Edwards Date: Mon, 22 Mar 2021 09:05:34 -0700 Subject: [PATCH 2/3] Revert "fix: revert breaking change for `compiler/preprocess` types location" This reverts commit 94c271c4334bc124d291fa23da6dc2c302e558e3. --- src/compiler/preprocess/decode_sourcemap.ts | 2 +- src/compiler/preprocess/index.ts | 34 +-------------------- src/compiler/preprocess/replace_in_code.ts | 2 +- src/compiler/preprocess/types.ts | 32 +++++++++++++++++++ src/compiler/utils/mapped_code.ts | 2 +- 5 files changed, 36 insertions(+), 36 deletions(-) create mode 100644 src/compiler/preprocess/types.ts diff --git a/src/compiler/preprocess/decode_sourcemap.ts b/src/compiler/preprocess/decode_sourcemap.ts index fc63c5b9c853..c7e13c28537f 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 441a64fee8ef..93b48996c186 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 450cf05edb57..9f49abb0f86e 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 000000000000..06890ad7b5ca --- /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 deda0f1e0be4..d0cab9f49fbf 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; From 3e57a260bcb802598ddeb21d5a25091e33e3d13b Mon Sep 17 00:00:00 2001 From: Luke Edwards Date: Mon, 22 Mar 2021 09:08:20 -0700 Subject: [PATCH 3/3] fix: re-export types from `compiler/preprocess` root --- src/compiler/preprocess/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/compiler/preprocess/index.ts b/src/compiler/preprocess/index.ts index 93b48996c186..16bcdf1687d4 100644 --- a/src/compiler/preprocess/index.ts +++ b/src/compiler/preprocess/index.ts @@ -5,6 +5,8 @@ import { decode_map } from './decode_sourcemap'; import { replace_in_code, slice_source } from './replace_in_code'; import { MarkupPreprocessor, Source, Preprocessor, PreprocessorGroup, Processed } from './types'; +export * from './types'; + interface SourceUpdate { string?: string; map?: DecodedSourceMap;