preserve js comments where possible (#4293)

pull/4299/head
Conduitry 5 years ago committed by GitHub
parent 9269212844
commit f12340acf0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -7,6 +7,7 @@
* Allow access to `let:` variables in sibling attributes on slot root ([#4173](https://github.com/sveltejs/svelte/issues/4173))
* Fix `~=` and class selector matching against values separated by any whitespace characters ([#4242](https://github.com/sveltejs/svelte/issues/4242))
* Fix code generation for `await`ed expressions that need parentheses ([#4267](https://github.com/sveltejs/svelte/issues/4267))
* Preserve JavaScript comments from the original component source where possible ([#4268](https://github.com/sveltejs/svelte/issues/4268))
* Add some more known globals ([#4276](https://github.com/sveltejs/svelte/pull/4276))
* Correctly apply event modifiers to `<svelte:body>` events ([#4278](https://github.com/sveltejs/svelte/issues/4278))

6
package-lock.json generated

@ -597,9 +597,9 @@
"dev": true
},
"code-red": {
"version": "0.0.30",
"resolved": "https://registry.npmjs.org/code-red/-/code-red-0.0.30.tgz",
"integrity": "sha512-nsScy3A59tbV5uzndcedIEGHmdWNEByJrC7DUyb0Wh7qZcoPfAlcYsr0ZINkAEhZofSI26F1mi+lRO0/6EV2/g==",
"version": "0.0.31",
"resolved": "https://registry.npmjs.org/code-red/-/code-red-0.0.31.tgz",
"integrity": "sha512-7Gf3vm8pDbs+H/hKsaqOZe0xKlE9Neah12GCfs7qun3fBUaOXwexAMjn0Eo9cvJJvhRMaL0jgPiY9ZGLTWoe8A==",
"dev": true,
"requires": {
"acorn": "^7.1.0",

@ -70,7 +70,7 @@
"acorn": "^7.1.0",
"agadoo": "^1.1.0",
"c8": "^5.0.1",
"code-red": "0.0.30",
"code-red": "0.0.31",
"codecov": "^3.5.0",
"css-tree": "1.0.0-alpha22",
"eslint": "^6.3.0",

@ -1,14 +1,13 @@
import * as acorn from 'acorn';
import { Node } from 'acorn';
import * as code_red from 'code-red';
const Parser = acorn.Parser;
export const parse = (source: string) => Parser.parse(source, {
export const parse = (source: string): Node => code_red.parse(source, {
sourceType: 'module',
ecmaVersion: 11,
locations: true
});
export const parse_expression_at = (source: string, index: number) => Parser.parseExpressionAt(source, index, {
export const parse_expression_at = (source: string, index: number): Node => code_red.parseExpressionAt(source, index, {
ecmaVersion: 11,
locations: true
});

@ -43,7 +43,7 @@ function handleFoo(bar) {
function foo(node, callback) {
}
} // code goes here
function instance($$self, $$props, $$invalidate) {
let { bar } = $$props;

@ -63,11 +63,11 @@ function create_fragment(ctx) {
function handleTouchstart() {
}
} // ...
function handleClick() {
}
} // ...
class Component extends SvelteComponent {
constructor(options) {

@ -13,7 +13,7 @@ function foo() {
function swipe(node, callback) {
}
} // TODO implement
const Component = create_ssr_component(($$result, $$props, $$bindings, $$slots) => {
onMount(() => {

@ -41,7 +41,15 @@
}
},
"body": [],
"sourceType": "module"
"sourceType": "module",
"trailingComments": [
{
"type": "Line",
"value": " TODO write some code",
"start": 10,
"end": 33
}
]
}
}
}

@ -134,7 +134,15 @@
"kind": "let"
}
],
"sourceType": "module"
"sourceType": "module",
"trailingComments": [
{
"type": "Block",
"value": "\n\ttrailing multiline comment\n",
"start": 32,
"end": 67
}
]
}
}
}

@ -134,7 +134,15 @@
"kind": "let"
}
],
"sourceType": "module"
"sourceType": "module",
"trailingComments": [
{
"type": "Line",
"value": " trailing line comment",
"start": 32,
"end": 56
}
]
}
}
}
Loading…
Cancel
Save