Skip to content

Commit d893f8f

Browse files
committed
Merge branch 'master' into gh-708
2 parents 3d51c98 + 0a2fed8 commit d893f8f

13 files changed

+67
-1456
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ test/sourcemaps/samples/*/output.js
1313
test/sourcemaps/samples/*/output.js.map
1414
_actual.*
1515
_actual-bundle.*
16-
src/generators/dom/shared.ts
16+
src/generators/dom/shared.ts
17+
package-lock.json

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Svelte changelog
22

3+
## 1.25.1
4+
5+
* Better CSS sourcemaps ([#716](https://github.com/sveltejs/svelte/pull/716))
6+
37
## 1.25.0
48

59
* Fix hoisted event handlers ([#699](https://github.com/sveltejs/svelte/issues/699))

package-lock.json

-1,449
This file was deleted.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "svelte",
3-
"version": "1.25.0",
3+
"version": "1.25.1",
44
"description": "The magical disappearing UI framework",
55
"main": "compiler/svelte.js",
66
"files": [
@@ -65,7 +65,7 @@
6565
"glob": "^7.1.1",
6666
"jsdom": "^9.9.1",
6767
"locate-character": "^2.0.0",
68-
"magic-string": "^0.22.1",
68+
"magic-string": "^0.22.3",
6969
"mocha": "^3.2.0",
7070
"node-resolve": "^1.3.3",
7171
"nyc": "^10.0.0",

src/css/Stylesheet.ts

+7
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,13 @@ export default class Stylesheet {
175175
code.remove(0, this.parsed.css.start + 7);
176176
code.remove(this.parsed.css.end - 8, this.source.length);
177177

178+
walk(this.parsed.css, {
179+
enter: (node: Node) => {
180+
code.addSourcemapLocation(node.start);
181+
code.addSourcemapLocation(node.end);
182+
}
183+
});
184+
178185
const keyframes = new Map();
179186
this.atrules.forEach((atrule: Atrule) => {
180187
atrule.transform(code, this.id, keyframes);

test/helpers.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export function loadConfig(file) {
155155
delete require.cache[resolved];
156156
return require(resolved).default;
157157
} catch (err) {
158-
if (err.code === 'E_NOT_FOUND') {
158+
if (err.code === 'MODULE_NOT_FOUND') {
159159
return {};
160160
}
161161

test/sourcemaps/index.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as fs from "fs";
22
import * as path from "path";
33
import assert from "assert";
4-
import { svelte } from "../helpers.js";
4+
import { loadConfig, svelte } from "../helpers.js";
55
import { SourceMapConsumer } from "source-map";
66
import { getLocator } from "locate-character";
77

@@ -17,6 +17,8 @@ describe("sourcemaps", () => {
1717
}
1818

1919
(solo ? it.only : it)(dir, () => {
20+
const config = loadConfig(`./sourcemaps/samples/${dir}/_config.js`);
21+
2022
const filename = path.resolve(
2123
`test/sourcemaps/samples/${dir}/input.html`
2224
);
@@ -28,7 +30,8 @@ describe("sourcemaps", () => {
2830
const { code, map, css, cssMap } = svelte.compile(input, {
2931
filename,
3032
outputFilename: `${outputFilename}.js`,
31-
cssOutputFilename: `${outputFilename}.css`
33+
cssOutputFilename: `${outputFilename}.css`,
34+
cascade: config.cascade
3235
});
3336

3437
fs.writeFileSync(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default {
2+
cascade: false
3+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<p class='foo'>red</p>
2+
3+
<style>
4+
.foo {
5+
color: red;
6+
}
7+
</style>

test/sourcemaps/samples/css-cascade-false/output.css

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/sourcemaps/samples/css-cascade-false/output.css.map

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
export function test ({ assert, smcCss, locateInSource, locateInGeneratedCss }) {
2+
const expected = locateInSource( '.foo' );
3+
4+
const loc = locateInGeneratedCss( '.foo' );
5+
6+
const actual = smcCss.originalPositionFor({
7+
line: loc.line + 1,
8+
column: loc.column
9+
});
10+
11+
assert.deepEqual( actual, {
12+
source: 'input.html',
13+
name: null,
14+
line: expected.line + 1,
15+
column: expected.column
16+
});
17+
}

test/sourcemaps/samples/css/output.css.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)