diff --git a/CHANGELOG.md b/CHANGELOG.md index 59bdc33c5b..81ef8805d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Svelte changelog +## 3.44.0 + +* Add `enableSourcemap` compiler option ([#6835](https://github.com/sveltejs/svelte/pull/6835)) + +## 3.43.2 + +* Fix regression where user-specified `import`s were not rewritten according to the `sveltePath` option ([#6834](https://github.com/sveltejs/svelte/issues/6834)) + ## 3.43.1 * Prevent a rejecting promise used in `{#await}` during SSR from appearing as an unhandled rejection ([#6789](https://github.com/sveltejs/svelte/issues/6789)) diff --git a/package-lock.json b/package-lock.json index fffe3c5df3..e8bc9889a7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,12 @@ { "name": "svelte", - "version": "3.43.1", + "version": "3.44.0", "lockfileVersion": 2, "requires": true, "packages": { "": { - "version": "3.43.1", + "name": "svelte", + "version": "3.44.0", "license": "MIT", "devDependencies": { "@ampproject/remapping": "^0.3.0", @@ -16,7 +17,7 @@ "@rollup/plugin-sucrase": "^3.1.0", "@rollup/plugin-typescript": "^2.0.1", "@rollup/plugin-virtual": "^2.0.0", - "@sveltejs/eslint-config": "github:sveltejs/eslint-config#v5.7.0", + "@sveltejs/eslint-config": "github:sveltejs/eslint-config#v5.8.0", "@types/mocha": "^7.0.0", "@types/node": "^8.10.53", "@typescript-eslint/eslint-plugin": "^4.31.2", @@ -5804,7 +5805,7 @@ "@sveltejs/eslint-config": { "version": "git+ssh://git@github.com/sveltejs/eslint-config.git#31fd4faeea88990069502460b023698b1c9c2d13", "dev": true, - "from": "@sveltejs/eslint-config@github:sveltejs/eslint-config#v5.7.0" + "from": "@sveltejs/eslint-config@github:sveltejs/eslint-config#v5.8.0" }, "@tootallnate/once": { "version": "1.0.0", diff --git a/package.json b/package.json index 997b54b5d3..60ee4f179d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "svelte", - "version": "3.43.1", + "version": "3.44.0", "description": "Cybernetically enhanced web apps", "module": "index.mjs", "main": "index", @@ -111,7 +111,7 @@ "@rollup/plugin-sucrase": "^3.1.0", "@rollup/plugin-typescript": "^2.0.1", "@rollup/plugin-virtual": "^2.0.0", - "@sveltejs/eslint-config": "github:sveltejs/eslint-config#v5.7.0", + "@sveltejs/eslint-config": "github:sveltejs/eslint-config#v5.8.0", "@types/mocha": "^7.0.0", "@types/node": "^8.10.53", "@typescript-eslint/eslint-plugin": "^4.31.2", diff --git a/site/content/docs/04-compile-time.md b/site/content/docs/04-compile-time.md index ed6977f81f..843daf2f84 100644 --- a/site/content/docs/04-compile-time.md +++ b/site/content/docs/04-compile-time.md @@ -82,6 +82,8 @@ The following options can be passed to the compiler. None are required: | `loopGuardTimeout` | 0 | A `number` that tells Svelte to break the loop if it blocks the thread for more than `loopGuardTimeout` ms. This is useful to prevent infinite loops. **Only available when `dev: true`** | `preserveComments` | `false` | If `true`, your HTML comments will be preserved during server-side rendering. By default, they are stripped out. | `preserveWhitespace` | `false` | If `true`, whitespace inside and between elements is kept as you typed it, rather than removed or collapsed to a single space where possible. +| `sourcemap` | `object \| string` | An initial sourcemap that will be merged into the final output sourcemap. This is usually the preprocessor sourcemap. +| `enableSourcemap` | `boolean \| { js: boolean; css: boolean; }` | If `true`, Svelte generate sourcemaps for components. Use an object with `js` or `css` for more granular control of sourcemap generation. By default, this is `true`. | `outputFilename` | `null` | A `string` used for your JavaScript sourcemap. | `cssOutputFilename` | `null` | A `string` used for your CSS sourcemap. | `sveltePath` | `"svelte"` | The location of the `svelte` package. Any imports from `svelte` or `svelte/[module]` will be modified accordingly. diff --git a/site/content/examples/09-transitions/04-custom-js-transitions/App.svelte b/site/content/examples/09-transitions/04-custom-js-transitions/App.svelte index 5e1ad9863c..90701aeab4 100644 --- a/site/content/examples/09-transitions/04-custom-js-transitions/App.svelte +++ b/site/content/examples/09-transitions/04-custom-js-transitions/App.svelte @@ -30,7 +30,7 @@ {#if visible} -
+
The quick brown fox jumps over the lazy dog
{/if} diff --git a/site/content/tutorial/06-bindings/02-numeric-inputs/app-a/App.svelte b/site/content/tutorial/06-bindings/02-numeric-inputs/app-a/App.svelte index ac4fadf012..795090a8bd 100644 --- a/site/content/tutorial/06-bindings/02-numeric-inputs/app-a/App.svelte +++ b/site/content/tutorial/06-bindings/02-numeric-inputs/app-a/App.svelte @@ -13,4 +13,9 @@ -{a} + {b} = {a + b}
\ No newline at end of file +{a} + {b} = {a + b}
+ + \ No newline at end of file diff --git a/site/content/tutorial/06-bindings/02-numeric-inputs/app-b/App.svelte b/site/content/tutorial/06-bindings/02-numeric-inputs/app-b/App.svelte index 798d57e021..a419675623 100644 --- a/site/content/tutorial/06-bindings/02-numeric-inputs/app-b/App.svelte +++ b/site/content/tutorial/06-bindings/02-numeric-inputs/app-b/App.svelte @@ -13,4 +13,9 @@ -{a} + {b} = {a + b}
\ No newline at end of file +{a} + {b} = {a + b}
+ + \ No newline at end of file diff --git a/site/content/tutorial/10-transitions/05-custom-js-transitions/app-a/App.svelte b/site/content/tutorial/10-transitions/05-custom-js-transitions/app-a/App.svelte index 11a8ec3ef5..7ce4a86e92 100644 --- a/site/content/tutorial/10-transitions/05-custom-js-transitions/app-a/App.svelte +++ b/site/content/tutorial/10-transitions/05-custom-js-transitions/app-a/App.svelte @@ -16,7 +16,7 @@ {#if visible} -+
The quick brown fox jumps over the lazy dog
-{/if} \ No newline at end of file +{/if} diff --git a/site/content/tutorial/10-transitions/05-custom-js-transitions/app-b/App.svelte b/site/content/tutorial/10-transitions/05-custom-js-transitions/app-b/App.svelte index 5e1ad9863c..90701aeab4 100644 --- a/site/content/tutorial/10-transitions/05-custom-js-transitions/app-b/App.svelte +++ b/site/content/tutorial/10-transitions/05-custom-js-transitions/app-b/App.svelte @@ -30,7 +30,7 @@ {#if visible} -+
The quick brown fox jumps over the lazy dog
{/if} diff --git a/src/compiler/compile/Component.ts b/src/compiler/compile/Component.ts index 202e14fd98..4d4cf909fd 100644 --- a/src/compiler/compile/Component.ts +++ b/src/compiler/compile/Component.ts @@ -36,6 +36,7 @@ import { clone } from '../utils/clone'; import compiler_warnings from './compiler_warnings'; import compiler_errors from './compiler_errors'; import { extract_ignores_above_position, extract_svelte_ignore_from_comments } from '../utils/extract_svelte_ignore'; +import check_enable_sourcemap from './utils/check_enable_sourcemap'; interface ComponentOptions { namespace?: string; @@ -343,21 +344,28 @@ export default class Component { ? { code: null, map: null } : result.css; - const sourcemap_source_filename = get_sourcemap_source_filename(compile_options); + const js_sourcemap_enabled = check_enable_sourcemap(compile_options.enableSourcemap, 'js'); - js = print(program, { - sourceMapSource: sourcemap_source_filename - }); + if (!js_sourcemap_enabled) { + js = print(program); + js.map = null; + } else { + const sourcemap_source_filename = get_sourcemap_source_filename(compile_options); - js.map.sources = [ - sourcemap_source_filename - ]; + js = print(program, { + sourceMapSource: sourcemap_source_filename + }); - js.map.sourcesContent = [ - this.source - ]; + js.map.sources = [ + sourcemap_source_filename + ]; - js.map = apply_preprocessor_sourcemap(sourcemap_source_filename, js.map, compile_options.sourcemap as (string | RawSourceMap | DecodedSourceMap)); + js.map.sourcesContent = [ + this.source + ]; + + js.map = apply_preprocessor_sourcemap(sourcemap_source_filename, js.map, compile_options.sourcemap as (string | RawSourceMap | DecodedSourceMap)); + } } return { diff --git a/src/compiler/compile/create_module.ts b/src/compiler/compile/create_module.ts index 037b2b396e..c9f925c4b4 100644 --- a/src/compiler/compile/create_module.ts +++ b/src/compiler/compile/create_module.ts @@ -26,7 +26,7 @@ export default function create_module( helpers.sort((a, b) => (a.name < b.name) ? -1 : 1); globals.sort((a, b) => (a.name < b.name) ? -1 : 1); - + const formatter = wrappers[format]; if (!formatter) { @@ -43,7 +43,7 @@ function edit_source(source, sveltePath) { } function get_internal_globals( - globals: Array<{ name: string; alias: Identifier }>, + globals: Array<{ name: string; alias: Identifier }>, helpers: Array<{ name: string; alias: Identifier }> ) { return globals.length > 0 && { @@ -66,7 +66,7 @@ function get_internal_globals( init: helpers.find(({ name }) => name === 'globals').alias }] }; -} +} function esm( program: any, @@ -93,12 +93,15 @@ function esm( const internal_globals = get_internal_globals(globals, helpers); // edit user imports - imports.forEach(node => { - node.source.value = edit_source(node.source.value, sveltePath); - }); - exports_from.forEach(node => { - node.source!.value = edit_source(node.source!.value, sveltePath); - }); + function rewrite_import(node) { + const value = edit_source(node.source.value, sveltePath); + if (node.source.value !== value) { + node.source.value = value; + node.source.raw = null; + } + } + imports.forEach(rewrite_import); + exports_from.forEach(rewrite_import); const exports = module_exports.length > 0 && { type: 'ExportNamedDeclaration', diff --git a/src/compiler/compile/index.ts b/src/compiler/compile/index.ts index 96b24bceee..afe9c56cf4 100644 --- a/src/compiler/compile/index.ts +++ b/src/compiler/compile/index.ts @@ -13,6 +13,7 @@ const valid_options = [ 'name', 'filename', 'sourcemap', + 'enableSourcemap', 'generate', 'errorMode', 'varsReport', @@ -82,7 +83,7 @@ function validate_options(options: CompileOptions, warnings: Warning[]) { } export default function compile(source: string, options: CompileOptions = {}) { - options = Object.assign({ generate: 'dom', dev: false }, options); + options = Object.assign({ generate: 'dom', dev: false, enableSourcemap: true }, options); const stats = new Stats(); const warnings = []; diff --git a/src/compiler/compile/render_dom/index.ts b/src/compiler/compile/render_dom/index.ts index f74f4cdf1c..89af0c297c 100644 --- a/src/compiler/compile/render_dom/index.ts +++ b/src/compiler/compile/render_dom/index.ts @@ -10,6 +10,7 @@ import { ImportDeclaration, ClassDeclaration, FunctionExpression, Node, Statemen import { apply_preprocessor_sourcemap } from '../../utils/mapped_code'; import { RawSourceMap, DecodedSourceMap } from '@ampproject/remapping/dist/types/types'; import { flatten } from '../../utils/flatten'; +import check_enable_sourcemap from '../utils/check_enable_sourcemap'; export default function dom( component: Component, @@ -34,9 +35,15 @@ export default function dom( const css = component.stylesheet.render(options.filename, !options.customElement); - css.map = apply_preprocessor_sourcemap(options.filename, css.map, options.sourcemap as string | RawSourceMap | DecodedSourceMap); + const css_sourcemap_enabled = check_enable_sourcemap(options.enableSourcemap, 'css'); - const styles = component.stylesheet.has_styles && options.dev + if (css_sourcemap_enabled) { + css.map = apply_preprocessor_sourcemap(options.filename, css.map, options.sourcemap as string | RawSourceMap | DecodedSourceMap); + } else { + css.map = null; + } + + const styles = css_sourcemap_enabled && component.stylesheet.has_styles && options.dev ? `${css.code}\n/*# sourceMappingURL=${css.map.toUrl()} */` : css.code; @@ -521,7 +528,7 @@ export default function dom( constructor(options) { super(); - ${css.code && b`this.shadowRoot.innerHTML = \`\`;`} + ${css.code && b`this.shadowRoot.innerHTML = \`\`;`} @init(this, { target: this.shadowRoot, props: ${init_props}, customElement: true }, ${definition}, ${has_create_fragment ? 'create_fragment' : 'null'}, ${not_equal}, ${prop_indexes}, null, ${dirty}); diff --git a/src/compiler/compile/render_ssr/index.ts b/src/compiler/compile/render_ssr/index.ts index b35a6ce6ff..9d2c1cc60b 100644 --- a/src/compiler/compile/render_ssr/index.ts +++ b/src/compiler/compile/render_ssr/index.ts @@ -10,6 +10,7 @@ import { extract_names } from 'periscopic'; import { walk } from 'estree-walker'; import { invalidate } from '../render_dom/invalidate'; +import check_enable_sourcemap from '../utils/check_enable_sourcemap'; export default function ssr( component: Component, @@ -200,11 +201,13 @@ export default function ssr( main ].filter(Boolean); + const css_sourcemap_enabled = check_enable_sourcemap(options.enableSourcemap, 'css'); + const js = b` ${css.code ? b` const #css = { code: "${css.code}", - map: ${css.map ? string_literal(css.map.toString()) : 'null'} + map: ${css_sourcemap_enabled && css.map ? string_literal(css.map.toString()) : 'null'} };` : null} ${component.extract_javascript(component.ast.module)} diff --git a/src/compiler/compile/utils/check_enable_sourcemap.ts b/src/compiler/compile/utils/check_enable_sourcemap.ts new file mode 100644 index 0000000000..51f07c353a --- /dev/null +++ b/src/compiler/compile/utils/check_enable_sourcemap.ts @@ -0,0 +1,10 @@ +import { EnableSourcemap } from '../../interfaces'; + +export default function check_enable_sourcemap( + enable_sourcemap: EnableSourcemap, + namespace: keyof Extractloading...
`, - test({ assert, component, target }) { + test({ assert, target }) { return sleep(50).then(() => { assert.htmlEqual(target.innerHTML, `the answer is 42
diff --git a/test/runtime/samples/await-in-each/_config.js b/test/runtime/samples/await-in-each/_config.js index a648bbe38a..617194a95c 100644 --- a/test/runtime/samples/await-in-each/_config.js +++ b/test/runtime/samples/await-in-each/_config.js @@ -18,7 +18,7 @@ export default {a title: loading...
`, - test({ assert, component, target }) { + test({ assert, target }) { fulfil(42); return thePromise diff --git a/test/runtime/samples/await-then-catch-order/_config.js b/test/runtime/samples/await-then-catch-order/_config.js index f972520904..29fc074162 100644 --- a/test/runtime/samples/await-then-catch-order/_config.js +++ b/test/runtime/samples/await-then-catch-order/_config.js @@ -13,7 +13,7 @@ export default {loading...
true!
`, - test({ assert, component, target }) { + test({ assert, target }) { fulfil(42); return thePromise diff --git a/test/runtime/samples/await-then-catch-static/_config.js b/test/runtime/samples/await-then-catch-static/_config.js index 35fc865d44..6918986950 100644 --- a/test/runtime/samples/await-then-catch-static/_config.js +++ b/test/runtime/samples/await-then-catch-static/_config.js @@ -22,7 +22,7 @@ export default {loaded
`); - promise = new Promise((f, r) => { + promise = new Promise((f, _) => { fulfil = f; }); diff --git a/test/runtime/samples/await-then-destruct-array/_config.js b/test/runtime/samples/await-then-destruct-array/_config.js index 55c48481e0..58a66a698d 100644 --- a/test/runtime/samples/await-then-destruct-array/_config.js +++ b/test/runtime/samples/await-then-destruct-array/_config.js @@ -1,6 +1,6 @@ export default { props: { - thePromise: new Promise(resolve => {}) + thePromise: new Promise(_ => {}) }, html: ` diff --git a/test/runtime/samples/await-then-destruct-default/_config.js b/test/runtime/samples/await-then-destruct-default/_config.js index d0e5a49f28..151f2c91f7 100644 --- a/test/runtime/samples/await-then-destruct-default/_config.js +++ b/test/runtime/samples/await-then-destruct-default/_config.js @@ -1,5 +1,5 @@ export default { - async test({ assert, component, target }) { + async test({ assert, target }) { await Promise.resolve(); assert.htmlEqual( diff --git a/test/runtime/samples/await-then-destruct-object/_config.js b/test/runtime/samples/await-then-destruct-object/_config.js index 7d08ad3711..47e8422cc4 100644 --- a/test/runtime/samples/await-then-destruct-object/_config.js +++ b/test/runtime/samples/await-then-destruct-object/_config.js @@ -1,6 +1,6 @@ export default { props: { - thePromise: new Promise(resolve => {}) + thePromise: new Promise(_ => {}) }, html: ` diff --git a/test/runtime/samples/await-then-destruct-rest/_config.js b/test/runtime/samples/await-then-destruct-rest/_config.js index 528568e569..0a7445b535 100644 --- a/test/runtime/samples/await-then-destruct-rest/_config.js +++ b/test/runtime/samples/await-then-destruct-rest/_config.js @@ -1,5 +1,5 @@ export default { - async test({ assert, component, target }) { + async test({ assert, target }) { await Promise.resolve(); assert.htmlEqual( diff --git a/test/runtime/samples/await-then-if/_config.js b/test/runtime/samples/await-then-if/_config.js index f9e81dd2cc..f29f5df0e5 100644 --- a/test/runtime/samples/await-then-if/_config.js +++ b/test/runtime/samples/await-then-if/_config.js @@ -13,11 +13,11 @@ export default { loading... `, - async test({ assert, component, target }) { + async test({ assert, target }) { fulfil([]); await thePromise; - + assert.htmlEqual(target.innerHTML, `promise array is empty
`); diff --git a/test/runtime/samples/binding-input-group-duplicate-value/_config.js b/test/runtime/samples/binding-input-group-duplicate-value/_config.js index b5f3ae0115..db7dd84dee 100644 --- a/test/runtime/samples/binding-input-group-duplicate-value/_config.js +++ b/test/runtime/samples/binding-input-group-duplicate-value/_config.js @@ -17,7 +17,7 @@ export default { dx in parent: yes
`, - async test({ assert, component, target, window }) { + async test({ assert, component, target }) { component.a = false; assert.htmlEqual(target.innerHTML, ` diff --git a/test/runtime/samples/component-binding-parent-supercedes-child-c/_config.js b/test/runtime/samples/component-binding-parent-supercedes-child-c/_config.js index bf6312f5ad..4e31a4d79c 100644 --- a/test/runtime/samples/component-binding-parent-supercedes-child-c/_config.js +++ b/test/runtime/samples/component-binding-parent-supercedes-child-c/_config.js @@ -4,7 +4,7 @@ export default {x in parent: yes
`, - async test({ assert, component, target, window }) { + async test({ assert, component, target }) { component.a = false; assert.htmlEqual(target.innerHTML, ` diff --git a/test/runtime/samples/component-binding-private-state/_config.js b/test/runtime/samples/component-binding-private-state/_config.js index bd8a25d490..f4f2fd6f83 100644 --- a/test/runtime/samples/component-binding-private-state/_config.js +++ b/test/runtime/samples/component-binding-private-state/_config.js @@ -4,7 +4,7 @@ export default {x in parent: undefined
`, - async test({ assert, component, target, window }) { + async test({ assert, component, target }) { component.a = false; assert.htmlEqual(target.innerHTML, ` diff --git a/test/runtime/samples/component-binding-reactive-statement/_config.js b/test/runtime/samples/component-binding-reactive-statement/_config.js index 49342d0645..8b8d091c73 100644 --- a/test/runtime/samples/component-binding-reactive-statement/_config.js +++ b/test/runtime/samples/component-binding-reactive-statement/_config.js @@ -4,7 +4,7 @@ export default { `, - async test({ assert, component, target, window }) { + async test({ assert, target, window }) { const event = new window.MouseEvent('click'); const buttons = target.querySelectorAll('button'); diff --git a/test/runtime/samples/component-event-handler-contenteditable/_config.js b/test/runtime/samples/component-event-handler-contenteditable/_config.js index 3a85734975..1628e22d01 100644 --- a/test/runtime/samples/component-event-handler-contenteditable/_config.js +++ b/test/runtime/samples/component-event-handler-contenteditable/_config.js @@ -3,7 +3,7 @@ export default { `, - async test({ assert, component, target, window }) { + async test({ assert, target, window }) { const div = target.querySelector('div'); const text = window.document.createTextNode('a'); div.insertBefore(text, null); diff --git a/test/runtime/samples/component-events-console/_config.js b/test/runtime/samples/component-events-console/_config.js index 39ccbd719f..fc3b4daa85 100644 --- a/test/runtime/samples/component-events-console/_config.js +++ b/test/runtime/samples/component-events-console/_config.js @@ -1,7 +1,7 @@ export default { html: '', - test({ assert, component, target }) { + test({ assert, target }) { const button = target.querySelector('button'); const messages = []; diff --git a/test/runtime/samples/component-nested-deep/_config.js b/test/runtime/samples/component-nested-deep/_config.js index 0114e79223..3d5305529e 100644 --- a/test/runtime/samples/component-nested-deep/_config.js +++ b/test/runtime/samples/component-nested-deep/_config.js @@ -1,5 +1,5 @@ export default { - test({ assert, component }) { + test({ component }) { component.l1.$destroy(); } }; diff --git a/test/runtime/samples/component-nested-deeper/_config.js b/test/runtime/samples/component-nested-deeper/_config.js index 86993b3e9a..828a3169ac 100644 --- a/test/runtime/samples/component-nested-deeper/_config.js +++ b/test/runtime/samples/component-nested-deeper/_config.js @@ -3,7 +3,7 @@ export default { values: [1, 2, 3, 4] }, - test({ assert, component }) { + test({ component }) { component.values = [2, 3]; } }; diff --git a/test/runtime/samples/component-slot-attribute-order/_config.js b/test/runtime/samples/component-slot-attribute-order/_config.js index 54dc21c446..f4572317ca 100644 --- a/test/runtime/samples/component-slot-attribute-order/_config.js +++ b/test/runtime/samples/component-slot-attribute-order/_config.js @@ -4,7 +4,7 @@ export default { `, - async test({ assert, component, target, window }) { + async test({ assert, target, window }) { const [btn, btn1, btn2] = target.querySelectorAll('button'); await btn.dispatchEvent(new window.MouseEvent('click')); diff --git a/test/runtime/samples/component-slot-dynamic/_config.js b/test/runtime/samples/component-slot-dynamic/_config.js index 9e43ff15fe..9a6ed1a057 100644 --- a/test/runtime/samples/component-slot-dynamic/_config.js +++ b/test/runtime/samples/component-slot-dynamic/_config.js @@ -3,7 +3,7 @@ export default {override default slot
`, - test({ assert, component }) { + test({ component }) { component.nested.foo = 'b'; } }; diff --git a/test/runtime/samples/component-slot-let-destructured-2/_config.js b/test/runtime/samples/component-slot-let-destructured-2/_config.js index 38b04b7b5e..e407dcf2f8 100644 --- a/test/runtime/samples/component-slot-let-destructured-2/_config.js +++ b/test/runtime/samples/component-slot-let-destructured-2/_config.js @@ -13,7 +13,7 @@ export default {animals: aardvark
animals: buffalo
animals: chinchilla
countries: albania
countries: brazil
countries: china
people: alice
people: bob
people: carol
people: dave
', - test({ assert, component, target }) { + test() { // TODO } }; diff --git a/test/runtime/samples/each-blocks-nested/_config.js b/test/runtime/samples/each-blocks-nested/_config.js index 3318bc344d..04d9bd11c5 100644 --- a/test/runtime/samples/each-blocks-nested/_config.js +++ b/test/runtime/samples/each-blocks-nested/_config.js @@ -6,7 +6,6 @@ export default { html: 'selected: foo
`, - async test({ assert, component, target, window }) { + async test({ assert, target, window }) { const buttons = target.querySelectorAll('button'); const event = new window.MouseEvent('click'); diff --git a/test/runtime/samples/event-handler-sanitize/_config.js b/test/runtime/samples/event-handler-sanitize/_config.js index 9f16b14093..ddc15724a3 100644 --- a/test/runtime/samples/event-handler-sanitize/_config.js +++ b/test/runtime/samples/event-handler-sanitize/_config.js @@ -3,7 +3,7 @@ export default {x: 0
`, - async test({ assert, component, target, window }) { + async test({ assert, target, window }) { const buttons = target.querySelectorAll('button'); const click = new window.MouseEvent('click'); diff --git a/test/runtime/samples/instrumentation-script-loop-scope/_config.js b/test/runtime/samples/instrumentation-script-loop-scope/_config.js index 069114c523..1b57ed1e72 100644 --- a/test/runtime/samples/instrumentation-script-loop-scope/_config.js +++ b/test/runtime/samples/instrumentation-script-loop-scope/_config.js @@ -4,7 +4,7 @@ export default {x: 0
`, - async test({ assert, component, target, window }) { + async test({ assert, target, window }) { const buttons = target.querySelectorAll('button'); const click = new window.MouseEvent('click'); diff --git a/test/runtime/samples/instrumentation-script-update/_config.js b/test/runtime/samples/instrumentation-script-update/_config.js index 223904ad63..d662856a7b 100644 --- a/test/runtime/samples/instrumentation-script-update/_config.js +++ b/test/runtime/samples/instrumentation-script-update/_config.js @@ -4,7 +4,7 @@ export default {x: 0
`, - async test({ assert, component, target, window }) { + async test({ assert, target, window }) { const buttons = target.querySelectorAll('button'); const click = new window.MouseEvent('click'); diff --git a/test/runtime/samples/instrumentation-template-destructuring/_config.js b/test/runtime/samples/instrumentation-template-destructuring/_config.js index 2b677a8b3a..b8ccf586ae 100644 --- a/test/runtime/samples/instrumentation-template-destructuring/_config.js +++ b/test/runtime/samples/instrumentation-template-destructuring/_config.js @@ -6,7 +6,7 @@ export default {x: 0
`, - async test({ assert, component, target, window }) { + async test({ assert, target, window }) { const buttons = target.querySelectorAll('button'); const click = new window.MouseEvent('click'); diff --git a/test/runtime/samples/instrumentation-template-loop-scope/_config.js b/test/runtime/samples/instrumentation-template-loop-scope/_config.js index 069114c523..1b57ed1e72 100644 --- a/test/runtime/samples/instrumentation-template-loop-scope/_config.js +++ b/test/runtime/samples/instrumentation-template-loop-scope/_config.js @@ -4,7 +4,7 @@ export default {x: 0
`, - async test({ assert, component, target, window }) { + async test({ assert, target, window }) { const buttons = target.querySelectorAll('button'); const click = new window.MouseEvent('click'); diff --git a/test/runtime/samples/instrumentation-template-update/_config.js b/test/runtime/samples/instrumentation-template-update/_config.js index 223904ad63..d662856a7b 100644 --- a/test/runtime/samples/instrumentation-template-update/_config.js +++ b/test/runtime/samples/instrumentation-template-update/_config.js @@ -4,7 +4,7 @@ export default {x: 0
`, - async test({ assert, component, target, window }) { + async test({ assert, target, window }) { const buttons = target.querySelectorAll('button'); const click = new window.MouseEvent('click'); diff --git a/test/runtime/samples/key-block-2/_config.js b/test/runtime/samples/key-block-2/_config.js index 9bbf1f199f..9bb7f17140 100644 --- a/test/runtime/samples/key-block-2/_config.js +++ b/test/runtime/samples/key-block-2/_config.js @@ -1,7 +1,7 @@ // with reactive content beside `key` export default { html: '1 1 1
`, - test({ assert, component, target }) { + test({ assert, component }) { assert.equal(component.y, 1); assert.equal(component.z, 1); diff --git a/test/runtime/samples/reactive-values-fixed/_config.js b/test/runtime/samples/reactive-values-fixed/_config.js index 58aee09c35..9f25b3e24e 100644 --- a/test/runtime/samples/reactive-values-fixed/_config.js +++ b/test/runtime/samples/reactive-values-fixed/_config.js @@ -3,7 +3,7 @@ export default {4
`, - test({ assert, component, target }) { + test({ assert, target }) { assert.htmlEqual(target.innerHTML, `4
`); diff --git a/test/runtime/samples/reactive-values-second-order/_config.js b/test/runtime/samples/reactive-values-second-order/_config.js index c1dee87e2c..c70fb0641c 100644 --- a/test/runtime/samples/reactive-values-second-order/_config.js +++ b/test/runtime/samples/reactive-values-second-order/_config.js @@ -1,5 +1,5 @@ export default { - test({ assert, component, target }) { + test({ assert, component }) { assert.equal(component.qux, 2); component.foo = 2; diff --git a/test/runtime/samples/select-bind-in-array/_config.js b/test/runtime/samples/select-bind-in-array/_config.js index d104743d44..79c5641324 100644 --- a/test/runtime/samples/select-bind-in-array/_config.js +++ b/test/runtime/samples/select-bind-in-array/_config.js @@ -7,7 +7,7 @@ export default { items }, - test({ assert, component, target }) { + test({ assert, component }) { const items = component.items; assert.equal( items[0].id, 'a' ); diff --git a/test/runtime/samples/select-no-whitespace/_config.js b/test/runtime/samples/select-no-whitespace/_config.js index fbd4990317..b00b800033 100644 --- a/test/runtime/samples/select-no-whitespace/_config.js +++ b/test/runtime/samples/select-no-whitespace/_config.js @@ -1,5 +1,5 @@ export default { - test({ assert, component, target }) { + test({ assert, target }) { const select = target.querySelector( 'select' ); assert.equal( select.childNodes.length, 3 ); } diff --git a/test/runtime/samples/select-props/_config.js b/test/runtime/samples/select-props/_config.js index 640fee0ef7..93915d5b82 100644 --- a/test/runtime/samples/select-props/_config.js +++ b/test/runtime/samples/select-props/_config.js @@ -1,5 +1,5 @@ export default { - test({ assert, component, target, window }) { + test({ assert, component, window }) { const selects = document.querySelectorAll('select'); const event1 = new window.Event('change'); diff --git a/test/runtime/samples/set-after-destroy/_config.js b/test/runtime/samples/set-after-destroy/_config.js index 063c133b87..3411f0cc79 100644 --- a/test/runtime/samples/set-after-destroy/_config.js +++ b/test/runtime/samples/set-after-destroy/_config.js @@ -3,7 +3,7 @@ export default { x: 1 }, - test({ assert, component }) { + test({ component }) { component.$destroy(); component.x = 2; } diff --git a/test/runtime/samples/set-in-onstate-dedupes-renders/_config.js b/test/runtime/samples/set-in-onstate-dedupes-renders/_config.js index 1d572f52fa..9f50a3cf25 100644 --- a/test/runtime/samples/set-in-onstate-dedupes-renders/_config.js +++ b/test/runtime/samples/set-in-onstate-dedupes-renders/_config.js @@ -1,7 +1,7 @@ export default { skip: true, // nice-to-have – tricky though, so skipping for now - test({ assert, component }) { + test({ component }) { component.foo = { x: 2 }; } }; diff --git a/test/runtime/samples/spread-component-with-bind/_config.js b/test/runtime/samples/spread-component-with-bind/_config.js index 96eb3c9475..5394fa80e0 100644 --- a/test/runtime/samples/spread-component-with-bind/_config.js +++ b/test/runtime/samples/spread-component-with-bind/_config.js @@ -9,7 +9,7 @@ export default { `, - async test({ assert, component, target, window }) { + async test({ assert, target, window }) { const input = target.querySelector('input'); input.value = 'bar'; diff --git a/test/runtime/samples/spread-element-input-bind-group-with-value-attr/_config.js b/test/runtime/samples/spread-element-input-bind-group-with-value-attr/_config.js index 4bbc9d278c..5176fb976c 100644 --- a/test/runtime/samples/spread-element-input-bind-group-with-value-attr/_config.js +++ b/test/runtime/samples/spread-element-input-bind-group-with-value-attr/_config.js @@ -7,7 +7,7 @@ export default { html: '', - async test({ assert, component, target, window }) { + async test({ assert, target }) { const input = target.querySelector('input'); assert.equal(input.value, 'abc'); assert.equal(input.__value, 'abc'); diff --git a/test/runtime/samples/spread-element-input-select/_config.js b/test/runtime/samples/spread-element-input-select/_config.js index 7361e6bb31..7971a2a3fc 100644 --- a/test/runtime/samples/spread-element-input-select/_config.js +++ b/test/runtime/samples/spread-element-input-select/_config.js @@ -1,5 +1,5 @@ export default { - async test({ assert, component, target, window }) { + async test({ assert, component, target }) { const select = target.querySelector('select'); const [option1, option2] = select.childNodes; diff --git a/test/runtime/samples/spread-element-input-value-undefined/_config.js b/test/runtime/samples/spread-element-input-value-undefined/_config.js index 9a83dccd80..9f5c0b8e77 100644 --- a/test/runtime/samples/spread-element-input-value-undefined/_config.js +++ b/test/runtime/samples/spread-element-input-value-undefined/_config.js @@ -1,5 +1,5 @@ export default { - async test({ assert, component, target, window }) { + async test({ assert, component, target }) { const input = target.querySelector('input'); component.value = undefined; diff --git a/test/runtime/samples/spread-element-select-value-undefined/_config.js b/test/runtime/samples/spread-element-select-value-undefined/_config.js index 59cf59d662..0c2c76a119 100644 --- a/test/runtime/samples/spread-element-select-value-undefined/_config.js +++ b/test/runtime/samples/spread-element-select-value-undefined/_config.js @@ -1,5 +1,5 @@ export default { - async test({ assert, component, target, window }) { + async test({ assert, component, target }) { const select = target.querySelector('select'); assert.equal(select.value, '1'); diff --git a/test/runtime/samples/store-assignment-updates-property/_config.js b/test/runtime/samples/store-assignment-updates-property/_config.js index a1c41b9888..467e7782d6 100644 --- a/test/runtime/samples/store-assignment-updates-property/_config.js +++ b/test/runtime/samples/store-assignment-updates-property/_config.js @@ -6,7 +6,7 @@ export default { `, - async test({ assert, component, target, window }) { + async test({ assert, target, window }) { const [btn1, btn2] = target.querySelectorAll('button'); const click = new window.MouseEvent('click'); diff --git a/test/runtime/samples/store-auto-subscribe-in-reactive-declaration-2/_config.js b/test/runtime/samples/store-auto-subscribe-in-reactive-declaration-2/_config.js index 27189d58d7..560eb44a9a 100644 --- a/test/runtime/samples/store-auto-subscribe-in-reactive-declaration-2/_config.js +++ b/test/runtime/samples/store-auto-subscribe-in-reactive-declaration-2/_config.js @@ -4,7 +4,7 @@ export default {escaped: false
', - async test({ assert, component, target, window }) { + async test({ assert, target, window }) { const event = new window.KeyboardEvent('keydown', { key: 'Escape' }); diff --git a/test/runtime/samples/window-event/_config.js b/test/runtime/samples/window-event/_config.js index 90c6562f95..9abde274e9 100644 --- a/test/runtime/samples/window-event/_config.js +++ b/test/runtime/samples/window-event/_config.js @@ -3,7 +3,7 @@ export default { skip_if_ssr: true, // there's some kind of weird bug with this test... it compiles with the wrong require.extensions hook for some bizarre reason - async test({ assert, component, target, window }) { + async test({ assert, target, window }) { const event = new window.Event('resize'); Object.defineProperties(window, { diff --git a/test/sourcemaps/index.ts b/test/sourcemaps/index.ts index 903629c06b..fc021cd6a7 100644 --- a/test/sourcemaps/index.ts +++ b/test/sourcemaps/index.ts @@ -85,11 +85,13 @@ describe('sourcemaps', () => { ); } - assert.deepEqual( - js.map.sources.slice().sort(), - (config.js_map_sources || ['input.svelte']).sort(), - 'js.map.sources is wrong' - ); + if (js.map) { + assert.deepEqual( + js.map.sources.slice().sort(), + (config.js_map_sources || ['input.svelte']).sort(), + 'js.map.sources is wrong' + ); + } if (css.map) { assert.deepEqual( css.map.sources.slice().sort(), diff --git a/test/sourcemaps/samples/no-sourcemap/_config.js b/test/sourcemaps/samples/no-sourcemap/_config.js new file mode 100644 index 0000000000..5b84d40554 --- /dev/null +++ b/test/sourcemaps/samples/no-sourcemap/_config.js @@ -0,0 +1,5 @@ +export default { + compile_options: { + enableSourcemap: false + } +}; diff --git a/test/sourcemaps/samples/no-sourcemap/input.svelte b/test/sourcemaps/samples/no-sourcemap/input.svelte new file mode 100644 index 0000000000..6d39eaad0e --- /dev/null +++ b/test/sourcemaps/samples/no-sourcemap/input.svelte @@ -0,0 +1,11 @@ + + +{foo}
+ + diff --git a/test/sourcemaps/samples/no-sourcemap/test.js b/test/sourcemaps/samples/no-sourcemap/test.js new file mode 100644 index 0000000000..127459a54e --- /dev/null +++ b/test/sourcemaps/samples/no-sourcemap/test.js @@ -0,0 +1,4 @@ +export function test({ assert, js, css }) { + assert.equal(js.map, null); + assert.equal(css.map, null); +} diff --git a/test/sourcemaps/samples/only-css-sourcemap/_config.js b/test/sourcemaps/samples/only-css-sourcemap/_config.js new file mode 100644 index 0000000000..767e10a4b9 --- /dev/null +++ b/test/sourcemaps/samples/only-css-sourcemap/_config.js @@ -0,0 +1,5 @@ +export default { + compile_options: { + enableSourcemap: { css: true } + } +}; diff --git a/test/sourcemaps/samples/only-css-sourcemap/input.svelte b/test/sourcemaps/samples/only-css-sourcemap/input.svelte new file mode 100644 index 0000000000..6d39eaad0e --- /dev/null +++ b/test/sourcemaps/samples/only-css-sourcemap/input.svelte @@ -0,0 +1,11 @@ + + +{foo}
+ + diff --git a/test/sourcemaps/samples/only-css-sourcemap/test.js b/test/sourcemaps/samples/only-css-sourcemap/test.js new file mode 100644 index 0000000000..a7ac6a9b0b --- /dev/null +++ b/test/sourcemaps/samples/only-css-sourcemap/test.js @@ -0,0 +1,4 @@ +export function test({ assert, js, css }) { + assert.equal(js.map, null); + assert.notEqual(css.map, null); +} diff --git a/test/sourcemaps/samples/only-js-sourcemap/_config.js b/test/sourcemaps/samples/only-js-sourcemap/_config.js new file mode 100644 index 0000000000..0b3b7987f1 --- /dev/null +++ b/test/sourcemaps/samples/only-js-sourcemap/_config.js @@ -0,0 +1,5 @@ +export default { + compile_options: { + enableSourcemap: { js: true } + } +}; diff --git a/test/sourcemaps/samples/only-js-sourcemap/input.svelte b/test/sourcemaps/samples/only-js-sourcemap/input.svelte new file mode 100644 index 0000000000..6d39eaad0e --- /dev/null +++ b/test/sourcemaps/samples/only-js-sourcemap/input.svelte @@ -0,0 +1,11 @@ + + +{foo}
+ + diff --git a/test/sourcemaps/samples/only-js-sourcemap/test.js b/test/sourcemaps/samples/only-js-sourcemap/test.js new file mode 100644 index 0000000000..b150653c3d --- /dev/null +++ b/test/sourcemaps/samples/only-js-sourcemap/test.js @@ -0,0 +1,4 @@ +export function test({ assert, js, css }) { + assert.notEqual(js.map, null); + assert.equal(css.map, null); +}