@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.
@@ -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
- if ((0, _utils().isURL)(specifier)) {
175
- name.value = asset.addURLDependency(specifier, {
176
- loc: createLoc((0, _nullthrows().default)(rule.source.start), asset.filePath, 0, 8)
177
- });
178
- } else {
179
- // If this came from an inline <style> tag, don't inline the imported file. Replace with the correct URL instead.
180
- // TODO: run CSSPackager on inline style tags.
181
- // let inlineHTML =
182
- // this.options.rendition && this.options.rendition.inlineHTML;
183
- // if (inlineHTML) {
184
- // name.value = asset.addURLDependency(dep, {loc: rule.source.start});
185
- // rule.params = params.toString();
186
- // } else {
187
- media = _postcssValueParser().default.stringify(media).trim();
188
- let dep = {
189
- specifier,
190
- specifierType: 'url',
191
- // Offset by 8 as it does not include `@import `
192
- loc: createLoc((0, _nullthrows().default)(rule.source.start), specifier, 0, 8),
193
- meta: {
194
- // For the glob resolver to distinguish between `@import` and other URL dependencies.
195
- isCSSImport: true,
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: createLoc((0, _nullthrows().default)(decl.source.start), node.nodes[0].value, 0, node.nodes[0].sourceIndex)
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.0.0-rc.0",
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.0.0-beta.1"
20
+ "parcel": "^2.1.1"
21
21
  },
22
22
  "dependencies": {
23
- "@parcel/plugin": "2.0.0-rc.0",
24
- "@parcel/source-map": "2.0.0-rc.6",
25
- "@parcel/utils": "2.0.0-rc.0",
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.4.1"
29
+ "semver": "^5.7.1"
30
30
  },
31
- "gitHead": "8fc248f1f8eeb4428f7abd768bd23111451b1903"
31
+ "gitHead": "f53ffe772a8259d94ca2937d02fde149454112f3"
32
32
  }
@@ -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
- if (isURL(specifier)) {
112
- name.value = asset.addURLDependency(specifier, {
113
- loc: createLoc(nullthrows(rule.source.start), asset.filePath, 0, 8),
114
- });
115
- } else {
116
- // If this came from an inline <style> tag, don't inline the imported file. Replace with the correct URL instead.
117
- // TODO: run CSSPackager on inline style tags.
118
- // let inlineHTML =
119
- // this.options.rendition && this.options.rendition.inlineHTML;
120
- // if (inlineHTML) {
121
- // name.value = asset.addURLDependency(dep, {loc: rule.source.start});
122
- // rule.params = params.toString();
123
- // } else {
124
- media = valueParser.stringify(media).trim();
125
- let dep = {
126
- specifier,
127
- specifierType: 'url',
128
- // Offset by 8 as it does not include `@import `
129
- loc: createLoc(nullthrows(rule.source.start), specifier, 0, 8),
130
- meta: {
131
- // For the glob resolver to distinguish between `@import` and other URL dependencies.
132
- isCSSImport: true,
133
- media,
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: createLoc(
157
- nullthrows(decl.source.start),
158
- node.nodes[0].value,
159
- 0,
160
- node.nodes[0].sourceIndex,
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;