From 662aa2b2f308391efb766f273bf760877c1fb1e6 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Mon, 4 Dec 2017 22:09:50 -0500 Subject: [PATCH 1/8] -> v1.44.2 --- CHANGELOG.md | 7 ++++++- package.json | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 048b070a1e..66a50dc3fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,13 @@ # Svelte changelog +## 1.44.2 + +* Fix `await` blocks with siblings ([#974](https://github.com/sveltejs/svelte/issues/974)) +* Fix `await` blocks inside `if` blocks ([#975](https://github.com/sveltejs/svelte/issues/975)) + ## 1.44.1 -* Fix bidirectional transitions that reference state ([#962](https://github.com/sveltejs/svelte/issues962)) +* Fix bidirectional transitions that reference state ([#962](https://github.com/sveltejs/svelte/issues/962)) ## 1.44.0 diff --git a/package.json b/package.json index b033530acc..ef2119f802 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "svelte", - "version": "1.44.1", + "version": "1.44.2", "description": "The magical disappearing UI framework", "main": "compiler/svelte.js", "files": [ From de9ac1240abcb68121f1ccf91f9f40779a03efc6 Mon Sep 17 00:00:00 2001 From: Pat Cavit Date: Tue, 5 Dec 2017 12:28:11 -0800 Subject: [PATCH 2/8] WIP: pass options object to preprocess hooks So that file id (& eventually other options?) can be passed to each of the preprocess hooks --- src/index.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/index.ts b/src/index.ts index 081660d3d8..fb774a2fb7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -50,7 +50,7 @@ function parseAttributes(str: string) { return attrs; } -async function replaceTagContents(source, type: 'script' | 'style', preprocessor: Preprocessor) { +async function replaceTagContents(source, type: 'script' | 'style', preprocessor: Preprocessor, options: PreprocessOptions) { const exp = new RegExp(`<${type}([\\S\\s]*?)>([\\S\\s]*?)<\\/${type}>`, 'ig'); const match = exp.exec(source); @@ -59,7 +59,8 @@ async function replaceTagContents(source, type: 'script' | 'style', preprocessor const content: string = match[2]; const processed: { code: string, map?: SourceMap | string } = await preprocessor({ content, - attributes + attributes, + options }); if (processed && processed.code) { @@ -77,16 +78,19 @@ async function replaceTagContents(source, type: 'script' | 'style', preprocessor export async function preprocess(source: string, options: PreprocessOptions) { const { markup, style, script } = options; if (!!markup) { - const processed: { code: string, map?: SourceMap | string } = await markup({ content: source }); + const processed: { code: string, map?: SourceMap | string } = await markup({ + content: source, + options + }); source = processed.code; } if (!!style) { - source = await replaceTagContents(source, 'style', style); + source = await replaceTagContents(source, 'style', style, options); } if (!!script) { - source = await replaceTagContents(source, 'script', script); + source = await replaceTagContents(source, 'script', script, options); } return { From 9748e90e863a330a04ad3a022a40b166ca522844 Mon Sep 17 00:00:00 2001 From: Pat Cavit Date: Tue, 5 Dec 2017 12:28:43 -0800 Subject: [PATCH 3/8] WIP: interface --- src/interfaces.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/interfaces.ts b/src/interfaces.ts index 0d884f8472..51b45983ae 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -83,9 +83,10 @@ export interface CustomElementOptions { } export interface PreprocessOptions { - markup?: (options: {content: string}) => { code: string, map?: SourceMap | string }; + markup?: (options: {content: string, options: PreprocessOptions}) => { code: string, map?: SourceMap | string }; style?: Preprocessor; script?: Preprocessor; + id?: string } -export type Preprocessor = (options: {content: string, attributes: Record}) => { code: string, map?: SourceMap | string }; +export type Preprocessor = (options: {content: string, attributes: Record, options: PreprocessOptions}) => { code: string, map?: SourceMap | string }; From be8bc797d208722c34e81194ab63dd195548dcaf Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 7 Dec 2017 10:19:19 -0500 Subject: [PATCH 4/8] -> v1.45.0 --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 66a50dc3fd..5fe5f92535 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Svelte changelog +## 1.45.0 + +* Dynamic components ([#971](https://github.com/sveltejs/svelte/pull/971)) + ## 1.44.2 * Fix `await` blocks with siblings ([#974](https://github.com/sveltejs/svelte/issues/974)) diff --git a/package.json b/package.json index ef2119f802..89500a6165 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "svelte", - "version": "1.44.2", + "version": "1.45.0", "description": "The magical disappearing UI framework", "main": "compiler/svelte.js", "files": [ From b4a80c552631c6d304f8a59d99951b42d8d717a6 Mon Sep 17 00:00:00 2001 From: Pat Cavit Date: Thu, 7 Dec 2017 10:32:39 -0800 Subject: [PATCH 5/8] WIP: pass just filename param --- src/index.ts | 4 ++-- src/interfaces.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index fb774a2fb7..1caf5b5abc 100644 --- a/src/index.ts +++ b/src/index.ts @@ -60,7 +60,7 @@ async function replaceTagContents(source, type: 'script' | 'style', preprocessor const processed: { code: string, map?: SourceMap | string } = await preprocessor({ content, attributes, - options + filename : options.filename }); if (processed && processed.code) { @@ -80,7 +80,7 @@ export async function preprocess(source: string, options: PreprocessOptions) { if (!!markup) { const processed: { code: string, map?: SourceMap | string } = await markup({ content: source, - options + filename: options.filename }); source = processed.code; } diff --git a/src/interfaces.ts b/src/interfaces.ts index 51b45983ae..f2923c0788 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -86,7 +86,7 @@ export interface PreprocessOptions { markup?: (options: {content: string, options: PreprocessOptions}) => { code: string, map?: SourceMap | string }; style?: Preprocessor; script?: Preprocessor; - id?: string + filename?: string } -export type Preprocessor = (options: {content: string, attributes: Record, options: PreprocessOptions}) => { code: string, map?: SourceMap | string }; +export type Preprocessor = (options: {content: string, attributes: Record, filename?: string}) => { code: string, map?: SourceMap | string }; From 92dfabe3dc647fae9b59d9069f577a9a7e9601e0 Mon Sep 17 00:00:00 2001 From: Pat Cavit Date: Thu, 7 Dec 2017 10:49:09 -0800 Subject: [PATCH 6/8] WIP: fix args to markup hook --- src/interfaces.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/interfaces.ts b/src/interfaces.ts index f2923c0788..9773d330d3 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -83,7 +83,7 @@ export interface CustomElementOptions { } export interface PreprocessOptions { - markup?: (options: {content: string, options: PreprocessOptions}) => { code: string, map?: SourceMap | string }; + markup?: (options: {content: string, filename: string}) => { code: string, map?: SourceMap | string }; style?: Preprocessor; script?: Preprocessor; filename?: string From 304bd7464a484252fe55d3b01dff3096e870de0f Mon Sep 17 00:00:00 2001 From: Pat Cavit Date: Thu, 7 Dec 2017 10:49:28 -0800 Subject: [PATCH 7/8] test: filename passed to hooks --- test/preprocess/index.js | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/test/preprocess/index.js b/test/preprocess/index.js index 29eaff67f1..6ed452f672 100644 --- a/test/preprocess/index.js +++ b/test/preprocess/index.js @@ -126,6 +126,41 @@ describe('preprocess', () => { }); }); + it('provides filename to processing hooks', () => { + const source = ` +

Hello __MARKUP_FILENAME__!

+ + + `; + + const expected = ` +

Hello file.html!

+ + + `; + + return svelte.preprocess(source, { + filename: 'file.html', + markup: ({ content, filename }) => { + return { + code: content.replace('__MARKUP_FILENAME__', filename) + }; + }, + style: ({ content, filename }) => { + return { + code: content.replace('__STYLE_FILENAME__', filename) + }; + }, + script: ({ content, filename }) => { + return { + code: content.replace('__SCRIPT_FILENAME__', filename) + }; + } + }).then(processed => { + assert.equal(processed.toString(), expected); + }); + }); + it('ignores null/undefined returned from preprocessor', () => { const source = `