diff --git a/src/modules/typescript/compileFromMemory.ts b/src/modules/typescript/compileFromMemory.ts index c669a9eb..baa5e67b 100644 --- a/src/modules/typescript/compileFromMemory.ts +++ b/src/modules/typescript/compileFromMemory.ts @@ -114,6 +114,7 @@ function createImportTransformerFromProgram(program: ts.Program) { continue; } } + newElements.push(spec); } diff --git a/src/transformers/scss.ts b/src/transformers/scss.ts index d01055db..3dcafdf7 100644 --- a/src/transformers/scss.ts +++ b/src/transformers/scss.ts @@ -34,14 +34,17 @@ const transformer: Transformer = async ({ implementation = sass = mod.default; } - const { renderSync, ...sassOptions }: Options.Sass = { + const { renderSync, prependData, ...restOptions } = { sourceMap: true, ...options, includePaths: getIncludePaths(filename, options.includePaths), outFile: `${filename}.css`, }; - sassOptions.data = options.data ? options.data + content : content; + const sassOptions = { + ...restOptions, + data: prependData ? prependData + content : content, + }; // scss errors if passed an empty string if (sassOptions.data.length === 0) { diff --git a/src/types/options.ts b/src/types/options.ts index 0d0656aa..cc5f8f8a 100644 --- a/src/types/options.ts +++ b/src/types/options.ts @@ -26,12 +26,13 @@ export interface Babel extends BabelOptions { } export type Pug = PugOptions; -export type Sass = Omit & { +export type Sass = Omit & { implementation?: { render?: typeof render; renderSync?: typeof renderSync; }; renderSync?: boolean; + prependData?: string; }; // from /~https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/less/index.d.ts#L80 export interface Less { diff --git a/test/fixtures/types.ts b/test/fixtures/types.ts index c25ea1d9..cbfedfd9 100644 --- a/test/fixtures/types.ts +++ b/test/fixtures/types.ts @@ -1,7 +1,7 @@ -export type AType = "test1" | "test2" +export type AType = 'test1' | 'test2'; export interface AInterface { - test: string + test: string; } -export const AValue: string = "test" +export const AValue: string = 'test'; -export default "String" \ No newline at end of file +export default 'String'; diff --git a/test/transformers/scss.test.ts b/test/transformers/scss.test.ts index 6e18ccb5..4afd2746 100644 --- a/test/transformers/scss.test.ts +++ b/test/transformers/scss.test.ts @@ -34,7 +34,7 @@ describe('transformer - scss', () => { const template = ``; const opts = getAutoPreprocess({ scss: { - data: '$color:red;div{color:$color}', + prependData: '$color:red;div{color:$color}', }, }); @@ -70,7 +70,7 @@ describe('transformer - scss', () => { const template = ``; const opts = getAutoPreprocess({ scss: { - data: '$color:blue;div{color:$color}', + prependData: '$color:blue;div{color:$color}', renderSync: true, }, });