Skip to content

Commit 97c90c5

Browse files
committed
3.0.0
1 parent 7775adf commit 97c90c5

File tree

9 files changed

+96
-88
lines changed

9 files changed

+96
-88
lines changed

.appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
environment:
44
matrix:
5-
- nodejs_version: 4
5+
- nodejs_version: 8
66

77
version: "{build}"
88
build: off

.editorconfig

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,16 @@ root = true
33
[*]
44
charset = utf-8
55
end_of_line = lf
6-
indent_size = unset
76
indent_style = tab
87
insert_final_newline = true
98
trim_trailing_whitespace = true
109

11-
[*.{json,yml}]
12-
indent_size = 2
13-
indent_style = space
14-
1510
[*.md]
16-
indent_style = space
1711
trim_trailing_whitespace = false
1812

13+
[*.{json,md,yml}]
14+
indent_size = 2
15+
indent_style = space
16+
1917
[test/*.css]
2018
insert_final_newline = false

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
node_modules
2-
index.bundle.js
2+
index.*.*
33
package-lock.json
44
*.log*
55
*.result.css

.rollup.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@ import babel from 'rollup-plugin-babel';
22

33
export default {
44
input: 'index.js',
5-
output: { file: 'index.bundle.js', format: 'cjs' },
5+
output: [
6+
{ file: 'index.cjs.js', format: 'cjs' },
7+
{ file: 'index.es.mjs', format: 'es' }
8+
],
69
plugins: [
710
babel({
811
presets: [
9-
['env', { modules: false, targets: { node: 4 } }]
12+
['@babel/env', { modules: false, targets: { node: 6 } }]
1013
]
1114
})
1215
]

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
language: node_js
44

55
node_js:
6-
- 4
6+
- 8
77

88
install:
99
- npm install

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changes to PostCSS Sass
22

3+
### 3.0.0 (October 4, 2018)
4+
5+
- Fixed: issue with sourcemaps 0.7.x returning a Promise instead of an Object
6+
- Updated: `node-sass` to 4.9.3 (minor)
7+
- Updated: `postcss` to 7.0.5 (major)
8+
- Updated: `source-map` to 0.7.3 (major for this project)
9+
310
### 2.0.0 (December 25, 2017)
411

512
- Added: custom `source-map` implemention with fix for

index.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,18 @@ export default postcss.plugin('postcss-sass', opts => (root, result) => {
5858
(sassError, sassResult) => sassError ? reject(sassError) : resolve(sassResult)
5959
)
6060
).then(
61-
({ css: sassCSS, map: sassMap }) => {
61+
({ css: sassCSS, map: sassMap }) => mergeSourceMaps(
62+
postMap.toJSON(),
63+
JSON.parse(sassMap)
64+
).then(prev => {
6265
// update root to post-node-sass ast
6366
result.root = postcss.parse(
6467
sassCSS.toString(),
6568
Object.assign({}, postConfig, {
66-
map: {
67-
prev: mergeSourceMaps(
68-
postMap.toJSON(),
69-
JSON.parse(sassMap)
70-
)
71-
}
69+
map: { prev }
7270
})
7371
);
74-
}
72+
})
7573
);
7674
});
7775

lib/merge-source-maps.js

Lines changed: 49 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -5,64 +5,68 @@ import { SourceMapConsumer, SourceMapGenerator } from 'source-map';
55
const sassMatch = /#sass$/;
66

77
// returns merged source maps
8-
export default function (...maps) {
8+
export default (...maps) => {
99
// new sourcemap
1010
const generator = new SourceMapGenerator();
1111

1212
// existing sourcemaps
13-
const consumers = maps.map(
13+
const consumersPromise = Promise.all(maps.map(
1414
map => new SourceMapConsumer(map)
15-
);
16-
17-
consumers.forEach(
18-
consumer => {
19-
// copy each original mapping to the new sourcemap
20-
consumer.eachMapping(
21-
mapping => {
22-
const originalPosition = originalPositionFor(mapping, consumers);
23-
24-
if (originalPosition.source) {
25-
generator.addMapping({
26-
generated: {
27-
line: mapping.generatedLine,
28-
column: mapping.generatedColumn
29-
},
30-
original: {
31-
// use positive numbers to work around sass/libsass#2312
32-
line: Math.abs(originalPosition.line),
33-
column: Math.abs(originalPosition.column)
34-
},
35-
source: originalPosition.source,
36-
name: originalPosition.name
37-
});
15+
));
16+
17+
return consumersPromise.then(
18+
consumers => consumers.forEach(
19+
consumer => {
20+
// copy each original mapping to the new sourcemap
21+
consumer.eachMapping(
22+
mapping => {
23+
const originalPosition = originalPositionFor(mapping, consumers);
24+
25+
if (originalPosition.source) {
26+
generator.addMapping({
27+
generated: {
28+
line: mapping.generatedLine,
29+
column: mapping.generatedColumn
30+
},
31+
original: {
32+
// use positive numbers to work around sass/libsass#2312
33+
line: Math.abs(originalPosition.line),
34+
column: Math.abs(originalPosition.column)
35+
},
36+
source: originalPosition.source,
37+
name: originalPosition.name
38+
});
39+
}
3840
}
39-
}
40-
);
41+
);
4142

42-
// copy each original source to the new sourcemap
43-
consumer.sources.forEach(
44-
source => {
45-
generator._sources.add(source);
43+
// copy each original source to the new sourcemap
44+
consumer.sources.forEach(
45+
source => {
46+
generator._sources.add(source);
4647

47-
const content = consumer.sourceContentFor(source);
48+
const content = consumer.sourceContentFor(source);
4849

49-
if (content !== null) {
50-
generator.setSourceContent(source, content);
50+
if (content !== null) {
51+
generator.setSourceContent(source, content);
52+
}
5153
}
52-
}
54+
);
55+
}
56+
)
57+
).then(
58+
() => {
59+
// merged map as json
60+
const mergedMap = JSON.parse(generator);
61+
62+
// clean all special sass sources in merged map
63+
mergedMap.sources = mergedMap.sources.map(
64+
source => source.replace(sassMatch, '')
5365
);
54-
}
55-
);
5666

57-
// merged map as json
58-
const mergedMap = JSON.parse(generator);
59-
60-
// clean all special sass sources in merged map
61-
mergedMap.sources = mergedMap.sources.map(
62-
source => source.replace(sassMatch, '')
67+
return mergedMap;
68+
}
6369
);
64-
65-
return mergedMap;
6670
}
6771

6872
function originalPositionFor(mapping, consumers) {

package.json

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,47 @@
11
{
22
"name": "@csstools/postcss-sass",
3-
"version": "2.0.0",
3+
"version": "3.0.0",
44
"description": "Use Sass as a PostCSS plugin",
55
"author": "Jonathan Neal <[email protected]>",
66
"license": "CC0-1.0",
77
"repository": "jonathantneal/postcss-sass",
88
"homepage": "https://github.com/jonathantneal/postcss-sass#readme",
99
"bugs": "https://github.com/jonathantneal/postcss-sass/issues",
10-
"main": "index.bundle.js",
11-
"module": "index.js",
10+
"main": "index.cjs.js",
11+
"module": "index.es.mjs",
1212
"files": [
13-
"index.js",
14-
"index.bundle.js",
15-
"lib"
13+
"index.es.mjs",
14+
"index.cjs.js"
1615
],
1716
"scripts": {
1817
"prepublishOnly": "npm test",
1918
"pretest": "rollup -c .rollup.js --silent",
20-
"test": "echo 'Running tests...'; npm run test:ec && npm run test:js && npm run test:tape",
21-
"test:ec": "echint --ignore index.bundle.js test",
19+
"test": "npm run test:js && npm run test:tape",
2220
"test:js": "eslint *.js --cache --ignore-path .gitignore --quiet",
2321
"test:tape": "postcss-tape"
2422
},
2523
"engines": {
2624
"node": ">=4.0.0"
2725
},
2826
"dependencies": {
29-
"@csstools/sass-import-resolve": "^1.0",
30-
"node-sass": "^4.7",
31-
"postcss": "^6.0",
32-
"source-map": "^0.6"
27+
"@csstools/sass-import-resolve": "^1.0.0",
28+
"node-sass": "^4.9.3",
29+
"postcss": "^7.0.5",
30+
"source-map": "~0.7.3"
3331
},
3432
"devDependencies": {
35-
"babel-core": "^6.26",
36-
"babel-eslint": "^8.1",
37-
"babel-preset-env": "^1.6",
38-
"echint": "^4.0",
39-
"eslint": "^4.14",
40-
"eslint-config-dev": "2.0",
41-
"postcss-import": "^11.0",
42-
"postcss-tape": "2.2",
43-
"postcss-unroot": "^1.0",
44-
"pre-commit": "^1.2",
45-
"rollup": "^0.53",
46-
"rollup-plugin-babel": "^3.0"
33+
"@babel/core": "^7.0.0",
34+
"@babel/preset-env": "^7.0.0",
35+
"babel-eslint": "^10.0.1",
36+
"echint": "^4.0.1",
37+
"eslint": "^5.6.1",
38+
"eslint-config-dev": "2.0.0",
39+
"postcss-import": "^12.0.0",
40+
"postcss-tape": "2.2.0",
41+
"postcss-unroot": "^1.0.2",
42+
"pre-commit": "^1.2.2",
43+
"rollup": "^0.66.4",
44+
"rollup-plugin-babel": "^4.0.1"
4745
},
4846
"eslintConfig": {
4947
"extends": "dev",

0 commit comments

Comments
 (0)