@atlaspack/transformer-less 2.14.5-canary.2 → 2.14.5-canary.200

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/CHANGELOG.md CHANGED
@@ -1,5 +1,210 @@
1
1
  # @atlaspack/transformer-less
2
2
 
3
+ ## 2.14.31
4
+
5
+ ### Patch Changes
6
+
7
+ - [#785](https://github.com/atlassian-labs/atlaspack/pull/785) [`0e7dd5e`](https://github.com/atlassian-labs/atlaspack/commit/0e7dd5ec6fbe05aa9e0bb5775a9d0975f206a922) Thanks [@matt-koko](https://github.com/matt-koko)! - We need to re-publish every package in Atlaspack with the corrected types field.
8
+
9
+ - Updated dependencies [[`0e7dd5e`](https://github.com/atlassian-labs/atlaspack/commit/0e7dd5ec6fbe05aa9e0bb5775a9d0975f206a922)]:
10
+ - @atlaspack/plugin@2.14.31
11
+ - @atlaspack/types-internal@2.20.1
12
+
13
+ ## 2.14.30
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies [[`eedcbc4`](https://github.com/atlassian-labs/atlaspack/commit/eedcbc408fc1e86a2a8e25f1a41c57146d8529e1), [`f6532d7`](https://github.com/atlassian-labs/atlaspack/commit/f6532d7a4f7f007bd4e5e36af04dd466f0b9f572)]:
18
+ - @atlaspack/types-internal@2.20.0
19
+ - @atlaspack/plugin@2.14.30
20
+
21
+ ## 2.14.29
22
+
23
+ ### Patch Changes
24
+
25
+ - Updated dependencies []:
26
+ - @atlaspack/types-internal@2.19.5
27
+ - @atlaspack/plugin@2.14.29
28
+
29
+ ## 2.14.28
30
+
31
+ ### Patch Changes
32
+
33
+ - Updated dependencies []:
34
+ - @atlaspack/types-internal@2.19.4
35
+ - @atlaspack/plugin@2.14.28
36
+
37
+ ## 2.14.27
38
+
39
+ ### Patch Changes
40
+
41
+ - Updated dependencies []:
42
+ - @atlaspack/types-internal@2.19.3
43
+ - @atlaspack/plugin@2.14.27
44
+
45
+ ## 2.14.26
46
+
47
+ ### Patch Changes
48
+
49
+ - [#742](https://github.com/atlassian-labs/atlaspack/pull/742) [`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd) Thanks [@yamadapc](https://github.com/yamadapc)! - Internal changes and bug fixes to environmentDeduplication flag
50
+
51
+ - Updated dependencies [[`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd)]:
52
+ - @atlaspack/types-internal@2.19.2
53
+ - @atlaspack/plugin@2.14.26
54
+
55
+ ## 2.14.25
56
+
57
+ ### Patch Changes
58
+
59
+ - Updated dependencies []:
60
+ - @atlaspack/types-internal@2.19.1
61
+ - @atlaspack/plugin@2.14.25
62
+
63
+ ## 2.14.24
64
+
65
+ ### Patch Changes
66
+
67
+ - Updated dependencies [[`7f5841c`](https://github.com/atlassian-labs/atlaspack/commit/7f5841c39df049f9546cccbeea2a7337e0337b45)]:
68
+ - @atlaspack/types-internal@2.19.0
69
+ - @atlaspack/plugin@2.14.24
70
+
71
+ ## 2.14.23
72
+
73
+ ### Patch Changes
74
+
75
+ - Updated dependencies []:
76
+ - @atlaspack/plugin@2.14.23
77
+
78
+ ## 2.14.22
79
+
80
+ ### Patch Changes
81
+
82
+ - [#720](https://github.com/atlassian-labs/atlaspack/pull/720) [`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94) Thanks [@alshdavid](https://github.com/alshdavid)! - Migrate to TypeScript
83
+
84
+ - Updated dependencies [[`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94)]:
85
+ - @atlaspack/plugin@2.14.22
86
+
87
+ ## 2.14.21
88
+
89
+ ### Patch Changes
90
+
91
+ - Updated dependencies []:
92
+ - @atlaspack/plugin@2.14.21
93
+
94
+ ## 2.14.20
95
+
96
+ ### Patch Changes
97
+
98
+ - [#702](https://github.com/atlassian-labs/atlaspack/pull/702) [`daaa768`](https://github.com/atlassian-labs/atlaspack/commit/daaa7688786772d7e3713b71c5bba6b89ec704aa) Thanks [@alshdavid](https://github.com/alshdavid)! - Fixes to Flow types
99
+
100
+ - Updated dependencies [[`daaa768`](https://github.com/atlassian-labs/atlaspack/commit/daaa7688786772d7e3713b71c5bba6b89ec704aa)]:
101
+ - @atlaspack/plugin@2.14.20
102
+
103
+ ## 2.14.19
104
+
105
+ ### Patch Changes
106
+
107
+ - Updated dependencies []:
108
+ - @atlaspack/plugin@2.14.19
109
+
110
+ ## 2.14.18
111
+
112
+ ### Patch Changes
113
+
114
+ - Updated dependencies []:
115
+ - @atlaspack/plugin@2.14.18
116
+
117
+ ## 2.14.17
118
+
119
+ ### Patch Changes
120
+
121
+ - Updated dependencies []:
122
+ - @atlaspack/plugin@2.14.17
123
+
124
+ ## 2.14.16
125
+
126
+ ### Patch Changes
127
+
128
+ - Updated dependencies []:
129
+ - @atlaspack/plugin@2.14.16
130
+
131
+ ## 2.14.15
132
+
133
+ ### Patch Changes
134
+
135
+ - Updated dependencies []:
136
+ - @atlaspack/plugin@2.14.15
137
+
138
+ ## 2.14.14
139
+
140
+ ### Patch Changes
141
+
142
+ - Updated dependencies []:
143
+ - @atlaspack/plugin@2.14.14
144
+
145
+ ## 2.14.13
146
+
147
+ ### Patch Changes
148
+
149
+ - Updated dependencies []:
150
+ - @atlaspack/plugin@2.14.13
151
+
152
+ ## 2.14.12
153
+
154
+ ### Patch Changes
155
+
156
+ - Updated dependencies []:
157
+ - @atlaspack/plugin@2.14.12
158
+
159
+ ## 2.14.11
160
+
161
+ ### Patch Changes
162
+
163
+ - Updated dependencies []:
164
+ - @atlaspack/plugin@2.14.11
165
+
166
+ ## 2.14.10
167
+
168
+ ### Patch Changes
169
+
170
+ - Updated dependencies []:
171
+ - @atlaspack/plugin@2.14.10
172
+
173
+ ## 2.14.9
174
+
175
+ ### Patch Changes
176
+
177
+ - Updated dependencies []:
178
+ - @atlaspack/plugin@2.14.9
179
+
180
+ ## 2.14.8
181
+
182
+ ### Patch Changes
183
+
184
+ - Updated dependencies []:
185
+ - @atlaspack/plugin@2.14.8
186
+
187
+ ## 2.14.7
188
+
189
+ ### Patch Changes
190
+
191
+ - Updated dependencies []:
192
+ - @atlaspack/plugin@2.14.7
193
+
194
+ ## 2.14.6
195
+
196
+ ### Patch Changes
197
+
198
+ - Updated dependencies []:
199
+ - @atlaspack/plugin@2.14.6
200
+
201
+ ## 2.14.5
202
+
203
+ ### Patch Changes
204
+
205
+ - Updated dependencies []:
206
+ - @atlaspack/plugin@2.14.5
207
+
3
208
  ## 2.14.4
4
209
 
5
210
  ### Patch Changes
@@ -34,6 +34,8 @@ function _less() {
34
34
  }
35
35
  var _loadConfig = require("./loadConfig");
36
36
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
37
+ // @ts-expect-error TS7016
38
+
37
39
  // E.g: ~library/file.less
38
40
  const WEBPACK_ALIAS_RE = /^~[^/]/;
39
41
  var _default = exports.default = new (_plugin().Transformer)({
@@ -83,6 +85,7 @@ var _default = exports.default = new (_plugin().Transformer)({
83
85
  let rawMap = JSON.parse(result.map);
84
86
  map.addVLQMap({
85
87
  ...rawMap,
88
+ // @ts-expect-error TS7006
86
89
  sources: rawMap.sources.map(s => _path().default.relative(options.projectRoot, s))
87
90
  });
88
91
  asset.setMap(map);
@@ -90,11 +93,12 @@ var _default = exports.default = new (_plugin().Transformer)({
90
93
  asset.setCode(result.css);
91
94
  return [asset];
92
95
  }
93
- });
96
+ }); // @ts-expect-error TS7031
94
97
  function urlPlugin({
95
98
  asset
96
99
  }) {
97
100
  return {
101
+ // @ts-expect-error TS2304
98
102
  install(less, pluginManager) {
99
103
  // This is a hack; no such interface exists, even conceptually, in Less.
100
104
 
@@ -109,13 +113,13 @@ function urlPlugin({
109
113
  return node;
110
114
  }
111
115
  });
112
-
113
- // $FlowFixMe[method-unbinding]
114
116
  visitor.run = visitor.visit;
115
117
  pluginManager.addVisitor(visitor);
116
118
  }
117
119
  };
118
120
  }
121
+
122
+ // @ts-expect-error TS7031
119
123
  function resolvePathPlugin({
120
124
  asset,
121
125
  resolve
package/lib/loadConfig.js CHANGED
@@ -20,10 +20,12 @@ async function load({
20
20
  });
21
21
  let configContents = {};
22
22
  if (configFile != null) {
23
+ // @ts-expect-error TS2322
23
24
  configContents = configFile.contents;
24
25
 
25
26
  // Resolve relative paths from config file
26
27
  if (configContents.paths) {
28
+ // @ts-expect-error TS7006
27
29
  configContents.paths = configContents.paths.map(p => _path().default.resolve(_path().default.dirname(configFile.filePath), p));
28
30
  }
29
31
  }
@@ -0,0 +1,3 @@
1
+ import { Transformer } from '@atlaspack/plugin';
2
+ declare const _default: Transformer<unknown>;
3
+ export default _default;
@@ -0,0 +1,8 @@
1
+ import type { Config } from '@atlaspack/types-internal';
2
+ type ConfigResult = {
3
+ config: any;
4
+ };
5
+ export declare function load({ config }: {
6
+ config: Config;
7
+ }): Promise<ConfigResult>;
8
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/transformer-less",
3
- "version": "2.14.5-canary.2+88fcaf47c",
3
+ "version": "2.14.5-canary.200+10ee3fa5b",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -9,16 +9,22 @@
9
9
  "type": "git",
10
10
  "url": "https://github.com/atlassian-labs/atlaspack.git"
11
11
  },
12
- "main": "lib/LessTransformer.js",
13
- "source": "src/LessTransformer.js",
12
+ "main": "./lib/LessTransformer.js",
13
+ "source": "./src/LessTransformer.ts",
14
+ "types": "./lib/types/LessTransformer.d.ts",
14
15
  "engines": {
15
16
  "node": ">= 16.0.0"
16
17
  },
17
18
  "dependencies": {
18
- "@atlaspack/plugin": "2.14.5-canary.2+88fcaf47c",
19
+ "@atlaspack/plugin": "2.14.5-canary.200+10ee3fa5b",
20
+ "@atlaspack/types-internal": "2.14.1-canary.268+10ee3fa5b",
19
21
  "@parcel/source-map": "^2.1.1",
20
22
  "less": "^4.1.1"
21
23
  },
22
24
  "type": "commonjs",
23
- "gitHead": "88fcaf47c77a6b7a16003028dd65a4b7a1f19dd7"
24
- }
25
+ "scripts": {
26
+ "check-ts": "tsc --emitDeclarationOnly --rootDir src",
27
+ "build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
28
+ },
29
+ "gitHead": "10ee3fa5b75a92acde8973673d9b3c5b6f3958e5"
30
+ }
@@ -1,8 +1,7 @@
1
- // @flow
2
- import {typeof default as Less} from 'less';
3
1
  import path from 'path';
4
2
  import {Transformer} from '@atlaspack/plugin';
5
3
  import SourceMap from '@parcel/source-map';
4
+ // @ts-expect-error TS7016
6
5
  import less from 'less';
7
6
 
8
7
  import {load} from './loadConfig';
@@ -11,13 +10,12 @@ import {load} from './loadConfig';
11
10
  const WEBPACK_ALIAS_RE = /^~[^/]/;
12
11
 
13
12
  type LessConfig = {
14
- sourceMap: any,
15
- filename: string,
16
- plugins: Array<any>,
17
- ...
13
+ sourceMap: any;
14
+ filename: string;
15
+ plugins: Array<any>;
18
16
  };
19
17
 
20
- export default (new Transformer({
18
+ export default new Transformer({
21
19
  loadConfig({config}) {
22
20
  return load({config});
23
21
  },
@@ -43,7 +41,7 @@ export default (new Transformer({
43
41
  ];
44
42
 
45
43
  result = await less.render(code, lessConfig);
46
- } catch (err) {
44
+ } catch (err: any) {
47
45
  // For the error reporter
48
46
  err.fileName = err.filename;
49
47
  err.loc = {
@@ -58,6 +56,7 @@ export default (new Transformer({
58
56
  let rawMap = JSON.parse(result.map);
59
57
  map.addVLQMap({
60
58
  ...rawMap,
59
+ // @ts-expect-error TS7006
61
60
  sources: rawMap.sources.map((s) =>
62
61
  path.relative(options.projectRoot, s),
63
62
  ),
@@ -69,18 +68,22 @@ export default (new Transformer({
69
68
 
70
69
  return [asset];
71
70
  },
72
- }): Transformer);
71
+ }) as Transformer<unknown>;
73
72
 
73
+ // @ts-expect-error TS7031
74
74
  function urlPlugin({asset}) {
75
75
  return {
76
- install(less: Less, pluginManager) {
76
+ // @ts-expect-error TS2304
77
+ install(less: Less, pluginManager: any) {
77
78
  // This is a hack; no such interface exists, even conceptually, in Less.
78
- type LessNodeWithValue = less.tree.Node & {value: any, ...};
79
+ type LessNodeWithValue = React.ReactNode & {
80
+ value: any;
81
+ };
79
82
 
80
83
  const visitor = new less.visitors.Visitor({
81
- visitUrl(node) {
82
- const valueNode = ((node.value: any): LessNodeWithValue);
83
- const stringValue = (valueNode.value: string);
84
+ visitUrl(node: any) {
85
+ const valueNode = node.value as LessNodeWithValue;
86
+ const stringValue = valueNode.value as string;
84
87
  if (
85
88
  !stringValue.startsWith('#') // IE's `behavior: url(#default#VML)`)
86
89
  ) {
@@ -90,16 +93,16 @@ function urlPlugin({asset}) {
90
93
  },
91
94
  });
92
95
 
93
- // $FlowFixMe[method-unbinding]
94
96
  visitor.run = visitor.visit;
95
97
  pluginManager.addVisitor(visitor);
96
98
  },
97
99
  };
98
100
  }
99
101
 
102
+ // @ts-expect-error TS7031
100
103
  function resolvePathPlugin({asset, resolve}) {
101
104
  return {
102
- install(less, pluginManager) {
105
+ install(less: any, pluginManager: any) {
103
106
  class LessFileManager extends less.FileManager {
104
107
  supports() {
105
108
  return true;
@@ -109,7 +112,7 @@ function resolvePathPlugin({asset, resolve}) {
109
112
  return false;
110
113
  }
111
114
 
112
- async loadFile(rawFilename, currentDirectory, options) {
115
+ async loadFile(rawFilename: any, currentDirectory: any, options: any) {
113
116
  let filename = rawFilename;
114
117
 
115
118
  if (WEBPACK_ALIAS_RE.test(filename)) {
@@ -146,7 +149,7 @@ function resolvePathPlugin({asset, resolve}) {
146
149
  try {
147
150
  contents = await asset.fs.readFile(filePath, 'utf8');
148
151
  break outer;
149
- } catch (err) {
152
+ } catch (err: any) {
150
153
  asset.invalidateOnFileCreate({filePath});
151
154
  }
152
155
  }
@@ -1,16 +1,11 @@
1
- // @flow
2
- import type {Config} from '@atlaspack/types';
1
+ import type {Config} from '@atlaspack/types-internal';
3
2
  import path from 'path';
4
3
 
5
- type ConfigResult = {|
6
- config: any,
7
- |};
4
+ type ConfigResult = {
5
+ config: any;
6
+ };
8
7
 
9
- export async function load({
10
- config,
11
- }: {|
12
- config: Config,
13
- |}): Promise<ConfigResult> {
8
+ export async function load({config}: {config: Config}): Promise<ConfigResult> {
14
9
  let configFile = await config.getConfig(
15
10
  ['.lessrc', '.lessrc.js', '.lessrc.cjs', '.lessrc.mjs'],
16
11
  {
@@ -18,12 +13,14 @@ export async function load({
18
13
  },
19
14
  );
20
15
 
21
- let configContents = {};
16
+ let configContents: Record<string, any> = {};
22
17
  if (configFile != null) {
18
+ // @ts-expect-error TS2322
23
19
  configContents = configFile.contents;
24
20
 
25
21
  // Resolve relative paths from config file
26
22
  if (configContents.paths) {
23
+ // @ts-expect-error TS7006
27
24
  configContents.paths = configContents.paths.map((p) =>
28
25
  path.resolve(path.dirname(configFile.filePath), p),
29
26
  );
package/tsconfig.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "../../../tsconfig.json",
3
+ "include": ["src"]
4
+ }