@parcel/transformer-less 2.8.4-nightly.0 → 2.9.0

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.
@@ -4,54 +4,38 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  function _path() {
9
8
  const data = _interopRequireDefault(require("path"));
10
-
11
9
  _path = function () {
12
10
  return data;
13
11
  };
14
-
15
12
  return data;
16
13
  }
17
-
18
14
  function _plugin() {
19
15
  const data = require("@parcel/plugin");
20
-
21
16
  _plugin = function () {
22
17
  return data;
23
18
  };
24
-
25
19
  return data;
26
20
  }
27
-
28
21
  function _sourceMap() {
29
22
  const data = _interopRequireDefault(require("@parcel/source-map"));
30
-
31
23
  _sourceMap = function () {
32
24
  return data;
33
25
  };
34
-
35
26
  return data;
36
27
  }
37
-
38
28
  function _less() {
39
29
  const data = _interopRequireDefault(require("less"));
40
-
41
30
  _less = function () {
42
31
  return data;
43
32
  };
44
-
45
33
  return data;
46
34
  }
47
-
48
35
  var _loadConfig = require("./loadConfig");
49
-
50
36
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
51
-
52
37
  // E.g: ~library/file.less
53
38
  const WEBPACK_ALIAS_RE = /^~[^/]/;
54
-
55
39
  var _default = new (_plugin().Transformer)({
56
40
  loadConfig({
57
41
  config
@@ -60,7 +44,6 @@ var _default = new (_plugin().Transformer)({
60
44
  config
61
45
  });
62
46
  },
63
-
64
47
  async transform({
65
48
  asset,
66
49
  options,
@@ -71,15 +54,13 @@ var _default = new (_plugin().Transformer)({
71
54
  asset.meta.hasDependencies = false;
72
55
  let code = await asset.getCode();
73
56
  let result;
74
-
75
57
  try {
76
- let lessConfig = config ? { ...config.config
58
+ let lessConfig = config ? {
59
+ ...config.config
77
60
  } : {};
78
-
79
61
  if (asset.env.sourceMap) {
80
62
  lessConfig.sourceMap = {};
81
63
  }
82
-
83
64
  lessConfig.filename = asset.filePath;
84
65
  lessConfig.plugins = [...(lessConfig.plugins || []), urlPlugin({
85
66
  asset
@@ -97,52 +78,45 @@ var _default = new (_plugin().Transformer)({
97
78
  };
98
79
  throw err;
99
80
  }
100
-
101
81
  if (result.map != null) {
102
82
  let map = new (_sourceMap().default)(options.projectRoot);
103
83
  let rawMap = JSON.parse(result.map);
104
- map.addVLQMap({ ...rawMap,
84
+ map.addVLQMap({
85
+ ...rawMap,
105
86
  sources: rawMap.sources.map(s => _path().default.relative(options.projectRoot, s))
106
87
  });
107
88
  asset.setMap(map);
108
89
  }
109
-
110
90
  asset.setCode(result.css);
111
91
  return [asset];
112
92
  }
113
-
114
93
  });
115
-
116
94
  exports.default = _default;
117
-
118
95
  function urlPlugin({
119
96
  asset
120
97
  }) {
121
98
  return {
122
99
  install(less, pluginManager) {
123
100
  // This is a hack; no such interface exists, even conceptually, in Less.
101
+
124
102
  const visitor = new less.visitors.Visitor({
125
103
  visitUrl(node) {
126
104
  const valueNode = node.value;
127
105
  const stringValue = valueNode.value;
128
-
129
106
  if (!stringValue.startsWith('#') // IE's `behavior: url(#default#VML)`)
130
107
  ) {
131
108
  valueNode.value = asset.addURLDependency(stringValue, {});
132
109
  }
133
-
134
110
  return node;
135
111
  }
112
+ });
136
113
 
137
- }); // $FlowFixMe[method-unbinding]
138
-
114
+ // $FlowFixMe[method-unbinding]
139
115
  visitor.run = visitor.visit;
140
116
  pluginManager.addVisitor(visitor);
141
117
  }
142
-
143
118
  };
144
119
  }
145
-
146
120
  function resolvePathPlugin({
147
121
  asset,
148
122
  resolve
@@ -153,45 +127,36 @@ function resolvePathPlugin({
153
127
  supports() {
154
128
  return true;
155
129
  }
156
-
157
130
  supportsSync() {
158
131
  return false;
159
132
  }
160
-
161
133
  async loadFile(rawFilename, currentDirectory, options) {
162
134
  let filename = rawFilename;
163
-
164
135
  if (WEBPACK_ALIAS_RE.test(filename)) {
165
136
  let correctPath = filename.replace(/^~/, '');
166
137
  throw new Error(`The @import path "${filename}" is using webpack specific syntax, which isn't supported by Parcel.\n\nTo @import files from node_modules, use "${correctPath}"`);
167
- } // Based on https://github.com/less/less.js/blob/master/packages/less/src/less-node/file-manager.js
168
-
138
+ }
169
139
 
140
+ // Based on https://github.com/less/less.js/blob/master/packages/less/src/less-node/file-manager.js
170
141
  let isAbsoluteFilename = this.isPathAbsolute(filename);
171
142
  let paths = isAbsoluteFilename ? [''] : [currentDirectory];
172
-
173
143
  if (options.paths) {
174
144
  paths.push(...options.paths);
175
145
  }
176
-
177
146
  let prefixes = options.prefixes || [''];
178
147
  let fileParts = this.extractUrlParts(filename);
179
148
  let filePath;
180
149
  let contents;
181
-
182
150
  if (filename[0] !== '~') {
183
151
  outer: for (let p of paths) {
184
152
  for (let prefix of prefixes) {
185
153
  filePath = fileParts.rawPath + prefix + fileParts.filename;
186
-
187
154
  if (p) {
188
155
  filePath = _path().default.join(p, filePath);
189
156
  }
190
-
191
157
  if (options.ext) {
192
158
  filePath = this.tryAppendExtension(filePath, options.ext);
193
159
  }
194
-
195
160
  try {
196
161
  contents = await asset.fs.readFile(filePath, 'utf8');
197
162
  break outer;
@@ -203,28 +168,22 @@ function resolvePathPlugin({
203
168
  }
204
169
  }
205
170
  }
206
-
207
171
  if (!contents) {
208
172
  filePath = await resolve(asset.filePath, filename, {
209
173
  packageConditions: ['less', 'style']
210
174
  });
211
175
  contents = await asset.fs.readFile(filePath, 'utf8');
212
176
  }
213
-
214
177
  if (filePath) {
215
178
  asset.invalidateOnFileChange(filePath);
216
179
  }
217
-
218
180
  return {
219
181
  contents,
220
182
  filename: filePath
221
183
  };
222
184
  }
223
-
224
185
  }
225
-
226
186
  pluginManager.addFileManager(new LessFileManager());
227
187
  }
228
-
229
188
  };
230
189
  }
package/lib/loadConfig.js CHANGED
@@ -4,19 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.load = load;
7
-
8
7
  function _path() {
9
8
  const data = _interopRequireDefault(require("path"));
10
-
11
9
  _path = function () {
12
10
  return data;
13
11
  };
14
-
15
12
  return data;
16
13
  }
17
-
18
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
-
20
15
  async function load({
21
16
  config
22
17
  }) {
@@ -24,16 +19,16 @@ async function load({
24
19
  packageKey: 'less'
25
20
  });
26
21
  let configContents = {};
27
-
28
22
  if (configFile != null) {
29
- configContents = configFile.contents; // Resolve relative paths from config file
23
+ configContents = configFile.contents;
30
24
 
25
+ // Resolve relative paths from config file
31
26
  if (configContents.paths) {
32
27
  configContents.paths = configContents.paths.map(p => _path().default.resolve(_path().default.dirname(configFile.filePath), p));
33
28
  }
34
- } // Rewrites urls to be relative to the provided filename
35
-
29
+ }
36
30
 
31
+ // Rewrites urls to be relative to the provided filename
37
32
  configContents.rewriteUrls = 'all';
38
33
  configContents.plugins = configContents.plugins || [];
39
34
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcel/transformer-less",
3
- "version": "2.8.4-nightly.0+7b79c6d",
3
+ "version": "2.9.0",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -17,12 +17,12 @@
17
17
  "source": "src/LessTransformer.js",
18
18
  "engines": {
19
19
  "node": ">= 12.0.0",
20
- "parcel": "2.8.4-nightly.0+7b79c6d"
20
+ "parcel": "^2.9.0"
21
21
  },
22
22
  "dependencies": {
23
- "@parcel/plugin": "2.8.4-nightly.0+7b79c6d",
23
+ "@parcel/plugin": "2.9.0",
24
24
  "@parcel/source-map": "^2.1.1",
25
25
  "less": "^4.1.1"
26
26
  },
27
- "gitHead": "7b79c6d69ffabef89810a8db61e9abdeb70d6990"
27
+ "gitHead": "dd9435be8afed35c5ffc161cf4b586fd6c78fc1f"
28
28
  }