@atlaspack/transformer-less 2.14.5-canary.18 → 2.14.5-canary.180

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,178 @@
1
1
  # @atlaspack/transformer-less
2
2
 
3
+ ## 2.14.29
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies []:
8
+ - @atlaspack/types-internal@2.19.5
9
+ - @atlaspack/plugin@2.14.29
10
+
11
+ ## 2.14.28
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies []:
16
+ - @atlaspack/types-internal@2.19.4
17
+ - @atlaspack/plugin@2.14.28
18
+
19
+ ## 2.14.27
20
+
21
+ ### Patch Changes
22
+
23
+ - Updated dependencies []:
24
+ - @atlaspack/types-internal@2.19.3
25
+ - @atlaspack/plugin@2.14.27
26
+
27
+ ## 2.14.26
28
+
29
+ ### Patch Changes
30
+
31
+ - [#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
32
+
33
+ - Updated dependencies [[`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd)]:
34
+ - @atlaspack/types-internal@2.19.2
35
+ - @atlaspack/plugin@2.14.26
36
+
37
+ ## 2.14.25
38
+
39
+ ### Patch Changes
40
+
41
+ - Updated dependencies []:
42
+ - @atlaspack/types-internal@2.19.1
43
+ - @atlaspack/plugin@2.14.25
44
+
45
+ ## 2.14.24
46
+
47
+ ### Patch Changes
48
+
49
+ - Updated dependencies [[`7f5841c`](https://github.com/atlassian-labs/atlaspack/commit/7f5841c39df049f9546cccbeea2a7337e0337b45)]:
50
+ - @atlaspack/types-internal@2.19.0
51
+ - @atlaspack/plugin@2.14.24
52
+
53
+ ## 2.14.23
54
+
55
+ ### Patch Changes
56
+
57
+ - Updated dependencies []:
58
+ - @atlaspack/plugin@2.14.23
59
+
60
+ ## 2.14.22
61
+
62
+ ### Patch Changes
63
+
64
+ - [#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
65
+
66
+ - Updated dependencies [[`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94)]:
67
+ - @atlaspack/plugin@2.14.22
68
+
69
+ ## 2.14.21
70
+
71
+ ### Patch Changes
72
+
73
+ - Updated dependencies []:
74
+ - @atlaspack/plugin@2.14.21
75
+
76
+ ## 2.14.20
77
+
78
+ ### Patch Changes
79
+
80
+ - [#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
81
+
82
+ - Updated dependencies [[`daaa768`](https://github.com/atlassian-labs/atlaspack/commit/daaa7688786772d7e3713b71c5bba6b89ec704aa)]:
83
+ - @atlaspack/plugin@2.14.20
84
+
85
+ ## 2.14.19
86
+
87
+ ### Patch Changes
88
+
89
+ - Updated dependencies []:
90
+ - @atlaspack/plugin@2.14.19
91
+
92
+ ## 2.14.18
93
+
94
+ ### Patch Changes
95
+
96
+ - Updated dependencies []:
97
+ - @atlaspack/plugin@2.14.18
98
+
99
+ ## 2.14.17
100
+
101
+ ### Patch Changes
102
+
103
+ - Updated dependencies []:
104
+ - @atlaspack/plugin@2.14.17
105
+
106
+ ## 2.14.16
107
+
108
+ ### Patch Changes
109
+
110
+ - Updated dependencies []:
111
+ - @atlaspack/plugin@2.14.16
112
+
113
+ ## 2.14.15
114
+
115
+ ### Patch Changes
116
+
117
+ - Updated dependencies []:
118
+ - @atlaspack/plugin@2.14.15
119
+
120
+ ## 2.14.14
121
+
122
+ ### Patch Changes
123
+
124
+ - Updated dependencies []:
125
+ - @atlaspack/plugin@2.14.14
126
+
127
+ ## 2.14.13
128
+
129
+ ### Patch Changes
130
+
131
+ - Updated dependencies []:
132
+ - @atlaspack/plugin@2.14.13
133
+
134
+ ## 2.14.12
135
+
136
+ ### Patch Changes
137
+
138
+ - Updated dependencies []:
139
+ - @atlaspack/plugin@2.14.12
140
+
141
+ ## 2.14.11
142
+
143
+ ### Patch Changes
144
+
145
+ - Updated dependencies []:
146
+ - @atlaspack/plugin@2.14.11
147
+
148
+ ## 2.14.10
149
+
150
+ ### Patch Changes
151
+
152
+ - Updated dependencies []:
153
+ - @atlaspack/plugin@2.14.10
154
+
155
+ ## 2.14.9
156
+
157
+ ### Patch Changes
158
+
159
+ - Updated dependencies []:
160
+ - @atlaspack/plugin@2.14.9
161
+
162
+ ## 2.14.8
163
+
164
+ ### Patch Changes
165
+
166
+ - Updated dependencies []:
167
+ - @atlaspack/plugin@2.14.8
168
+
169
+ ## 2.14.7
170
+
171
+ ### Patch Changes
172
+
173
+ - Updated dependencies []:
174
+ - @atlaspack/plugin@2.14.7
175
+
3
176
  ## 2.14.6
4
177
 
5
178
  ### 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.18+556d6ab8e",
3
+ "version": "2.14.5-canary.180+58b9fb037",
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.18+556d6ab8e",
19
+ "@atlaspack/plugin": "2.14.5-canary.180+58b9fb037",
20
+ "@atlaspack/types-internal": "2.14.1-canary.248+58b9fb037",
19
21
  "@parcel/source-map": "^2.1.1",
20
22
  "less": "^4.1.1"
21
23
  },
22
24
  "type": "commonjs",
23
- "gitHead": "556d6ab8ede759fa7f37fcd3f4da336ef1c55e8f"
25
+ "scripts": {
26
+ "check-ts": "tsc --emitDeclarationOnly --rootDir src",
27
+ "build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
28
+ },
29
+ "gitHead": "58b9fb037680a36a0b4af7890f2a03532095b88f"
24
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
+ }