Skip to content

Commit cab504f

Browse files
authored
fix: patch postcss 7 and bundle it in the published npm package (#111)
1 parent 8b0da74 commit cab504f

File tree

5 files changed

+954
-694
lines changed

5 files changed

+954
-694
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ node_modules
44
dist
55
coverage
66
.idea
7+
third_party

package.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@
66
"typings": "dist/index.d.ts",
77
"files": [
88
"dist",
9-
"lib"
9+
"lib",
10+
"third_party"
1011
],
1112
"scripts": {
1213
"lint": "prettier --write \"{lib,test}/**/*.ts\"",
14+
"pretest": "yarn clean && yarn patch-postcss",
1315
"test": "prettier --list-different \"{lib,test}/**/*.ts\" && jest --coverage",
14-
"build": "rm -rf dist && tsc",
16+
"clean": "rm -rf dist third_party",
17+
"patch-postcss": "patch-package && mkdir -p third_party/postcss && cp -R node_modules/postcss third_party/",
18+
"prebuild": "yarn clean && yarn patch-postcss",
19+
"build": "ttsc",
1520
"prepublishOnly": "yarn build && conventional-changelog -p angular -r 2 -i CHANGELOG.md -s"
1621
},
1722
"gitHooks": {
@@ -46,11 +51,15 @@
4651
"jest": "^24.0.0",
4752
"less": "^3.9.0",
4853
"lint-staged": "^8.1.1",
54+
"patch-package": "^6.4.7",
55+
"postcss": "^7.0.35",
4956
"pug": "^2.0.3",
5057
"sass": "^1.17.3",
5158
"stylus": "^0.54.5",
5259
"ts-jest": "^24.0.0",
60+
"ttypescript": "^1.5.12",
5361
"typescript": "^3.3.0",
62+
"typescript-transform-paths": "^2.2.4",
5463
"vue": "^2.6.6",
5564
"vue-template-compiler": "^2.6.6",
5665
"yorkie": "^2.0.0"
@@ -60,7 +69,6 @@
6069
"hash-sum": "^1.0.2",
6170
"lru-cache": "^4.1.2",
6271
"merge-source-map": "^1.1.0",
63-
"postcss": "^7.0.14",
6472
"postcss-selector-parser": "^6.0.2",
6573
"source-map": "~0.6.1",
6674
"vue-template-es2015-compiler": "^1.9.0"

patches/postcss+7.0.35.patch

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
diff --git a/node_modules/postcss/lib/previous-map.js b/node_modules/postcss/lib/previous-map.js
2+
index 49f99ad..ef0066d 100644
3+
--- a/node_modules/postcss/lib/previous-map.js
4+
+++ b/node_modules/postcss/lib/previous-map.js
5+
@@ -86,11 +86,11 @@ var PreviousMap = /*#__PURE__*/function () {
6+
};
7+
8+
_proto.getAnnotationURL = function getAnnotationURL(sourceMapString) {
9+
- return sourceMapString.match(/\/\*\s*# sourceMappingURL=(.*)\s*\*\//)[1].trim();
10+
+ return sourceMapString.match(/\/\*\s*# sourceMappingURL=(.*)\*\//)[1].trim()
11+
};
12+
13+
_proto.loadAnnotation = function loadAnnotation(css) {
14+
- var annotations = css.match(/\/\*\s*# sourceMappingURL=(.*)\s*\*\//mg);
15+
+ var annotations = css.match(/\/\*\s*# sourceMappingURL=.*\*\//gm);
16+
17+
if (annotations && annotations.length > 0) {
18+
// Locate the last sourceMappingURL to avoid picking up

tsconfig.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717
"lib": [
1818
"es6",
1919
"es7"
20+
],
21+
"paths": {
22+
"postcss": ["third_party/postcss"]
23+
},
24+
"plugins": [
25+
{ "transform": "typescript-transform-paths" },
26+
{ "transform": "typescript-transform-paths", "afterDeclarations": true }
2027
]
2128
},
2229
"include": [

0 commit comments

Comments
 (0)