@parcel/transformer-css 2.0.0-rc.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/CSSTransformer.js +25 -31
- package/package.json +7 -7
- package/src/CSSTransformer.js +33 -40
package/lib/CSSTransformer.js
CHANGED
|
@@ -169,36 +169,30 @@ var _default = new (_plugin().Transformer)({
|
|
|
169
169
|
|
|
170
170
|
if (!specifier) {
|
|
171
171
|
throw new Error('Could not find import name for ' + String(rule));
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
//
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
media
|
|
197
|
-
}
|
|
198
|
-
};
|
|
199
|
-
asset.addDependency(dep);
|
|
200
|
-
rule.remove(); // }
|
|
201
|
-
}
|
|
172
|
+
} // If this came from an inline <style> tag, don't inline the imported file. Replace with the correct URL instead.
|
|
173
|
+
// TODO: run CSSPackager on inline style tags.
|
|
174
|
+
// let inlineHTML =
|
|
175
|
+
// this.options.rendition && this.options.rendition.inlineHTML;
|
|
176
|
+
// if (inlineHTML) {
|
|
177
|
+
// name.value = asset.addURLDependency(dep, {loc: rule.source.start});
|
|
178
|
+
// rule.params = params.toString();
|
|
179
|
+
// } else {
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
media = _postcssValueParser().default.stringify(media).trim();
|
|
183
|
+
let dep = {
|
|
184
|
+
specifier,
|
|
185
|
+
specifierType: 'url',
|
|
186
|
+
// Offset by 8 as it does not include `@import `
|
|
187
|
+
loc: createLoc((0, _nullthrows().default)(rule.source.start), specifier, 0, 8),
|
|
188
|
+
meta: {
|
|
189
|
+
// For the glob resolver to distinguish between `@import` and other URL dependencies.
|
|
190
|
+
isCSSImport: true,
|
|
191
|
+
media
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
asset.addDependency(dep);
|
|
195
|
+
rule.remove(); // }
|
|
202
196
|
|
|
203
197
|
isDirty = true;
|
|
204
198
|
});
|
|
@@ -210,7 +204,7 @@ var _default = new (_plugin().Transformer)({
|
|
|
210
204
|
if (node.type === 'function' && node.value === 'url' && node.nodes.length > 0 && !node.nodes[0].value.startsWith('#') // IE's `behavior: url(#default#VML)`
|
|
211
205
|
) {
|
|
212
206
|
let url = asset.addURLDependency(node.nodes[0].value, {
|
|
213
|
-
loc:
|
|
207
|
+
loc: decl.source && decl.source.start && createLoc(decl.source.start, node.nodes[0].value, 0, node.nodes[0].sourceIndex)
|
|
214
208
|
});
|
|
215
209
|
isDeclDirty = node.nodes[0].value !== url;
|
|
216
210
|
node.nodes[0].value = url;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcel/transformer-css",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -17,16 +17,16 @@
|
|
|
17
17
|
"source": "src/CSSTransformer.js",
|
|
18
18
|
"engines": {
|
|
19
19
|
"node": ">= 12.0.0",
|
|
20
|
-
"parcel": "^2.
|
|
20
|
+
"parcel": "^2.1.1"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@parcel/plugin": "2.
|
|
24
|
-
"@parcel/source-map": "2.0.0
|
|
25
|
-
"@parcel/utils": "2.
|
|
23
|
+
"@parcel/plugin": "^2.1.1",
|
|
24
|
+
"@parcel/source-map": "^2.0.0",
|
|
25
|
+
"@parcel/utils": "^2.1.1",
|
|
26
26
|
"nullthrows": "^1.1.1",
|
|
27
27
|
"postcss": "^8.3.0",
|
|
28
28
|
"postcss-value-parser": "^4.1.0",
|
|
29
|
-
"semver": "^5.
|
|
29
|
+
"semver": "^5.7.1"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "f53ffe772a8259d94ca2937d02fde149454112f3"
|
|
32
32
|
}
|
package/src/CSSTransformer.js
CHANGED
|
@@ -5,11 +5,7 @@ import type {FilePath} from '@parcel/types';
|
|
|
5
5
|
|
|
6
6
|
import SourceMap from '@parcel/source-map';
|
|
7
7
|
import {Transformer} from '@parcel/plugin';
|
|
8
|
-
import {
|
|
9
|
-
createDependencyLocation,
|
|
10
|
-
isURL,
|
|
11
|
-
remapSourceLocation,
|
|
12
|
-
} from '@parcel/utils';
|
|
8
|
+
import {createDependencyLocation, remapSourceLocation} from '@parcel/utils';
|
|
13
9
|
import postcss from 'postcss';
|
|
14
10
|
import nullthrows from 'nullthrows';
|
|
15
11
|
import valueParser from 'postcss-value-parser';
|
|
@@ -108,35 +104,29 @@ export default (new Transformer({
|
|
|
108
104
|
throw new Error('Could not find import name for ' + String(rule));
|
|
109
105
|
}
|
|
110
106
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
//
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
},
|
|
135
|
-
};
|
|
136
|
-
asset.addDependency(dep);
|
|
137
|
-
rule.remove();
|
|
138
|
-
// }
|
|
139
|
-
}
|
|
107
|
+
// If this came from an inline <style> tag, don't inline the imported file. Replace with the correct URL instead.
|
|
108
|
+
// TODO: run CSSPackager on inline style tags.
|
|
109
|
+
// let inlineHTML =
|
|
110
|
+
// this.options.rendition && this.options.rendition.inlineHTML;
|
|
111
|
+
// if (inlineHTML) {
|
|
112
|
+
// name.value = asset.addURLDependency(dep, {loc: rule.source.start});
|
|
113
|
+
// rule.params = params.toString();
|
|
114
|
+
// } else {
|
|
115
|
+
media = valueParser.stringify(media).trim();
|
|
116
|
+
let dep = {
|
|
117
|
+
specifier,
|
|
118
|
+
specifierType: 'url',
|
|
119
|
+
// Offset by 8 as it does not include `@import `
|
|
120
|
+
loc: createLoc(nullthrows(rule.source.start), specifier, 0, 8),
|
|
121
|
+
meta: {
|
|
122
|
+
// For the glob resolver to distinguish between `@import` and other URL dependencies.
|
|
123
|
+
isCSSImport: true,
|
|
124
|
+
media,
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
asset.addDependency(dep);
|
|
128
|
+
rule.remove();
|
|
129
|
+
// }
|
|
140
130
|
isDirty = true;
|
|
141
131
|
});
|
|
142
132
|
|
|
@@ -153,12 +143,15 @@ export default (new Transformer({
|
|
|
153
143
|
!node.nodes[0].value.startsWith('#') // IE's `behavior: url(#default#VML)`
|
|
154
144
|
) {
|
|
155
145
|
let url = asset.addURLDependency(node.nodes[0].value, {
|
|
156
|
-
loc:
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
146
|
+
loc:
|
|
147
|
+
decl.source &&
|
|
148
|
+
decl.source.start &&
|
|
149
|
+
createLoc(
|
|
150
|
+
decl.source.start,
|
|
151
|
+
node.nodes[0].value,
|
|
152
|
+
0,
|
|
153
|
+
node.nodes[0].sourceIndex,
|
|
154
|
+
),
|
|
162
155
|
});
|
|
163
156
|
isDeclDirty = node.nodes[0].value !== url;
|
|
164
157
|
node.nodes[0].value = url;
|