@atlaspack/transformer-less 2.14.5-canary.138 → 2.14.5-canary.139
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/LessTransformer.d.ts +3 -0
- package/lib/LessTransformer.js +7 -4
- package/lib/loadConfig.d.ts +8 -0
- package/lib/loadConfig.js +2 -0
- package/package.json +10 -6
- package/src/{LessTransformer.js → LessTransformer.ts} +21 -19
- package/src/{loadConfig.js → loadConfig.ts} +7 -10
- package/tsconfig.json +4 -0
package/lib/LessTransformer.js
CHANGED
|
@@ -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)({
|
|
@@ -55,7 +57,6 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
55
57
|
let code = await asset.getCode();
|
|
56
58
|
let result;
|
|
57
59
|
try {
|
|
58
|
-
// $FlowFixMe
|
|
59
60
|
let lessConfig = config ? {
|
|
60
61
|
...config.config
|
|
61
62
|
} : {};
|
|
@@ -84,6 +85,7 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
84
85
|
let rawMap = JSON.parse(result.map);
|
|
85
86
|
map.addVLQMap({
|
|
86
87
|
...rawMap,
|
|
88
|
+
// @ts-expect-error TS7006
|
|
87
89
|
sources: rawMap.sources.map(s => _path().default.relative(options.projectRoot, s))
|
|
88
90
|
});
|
|
89
91
|
asset.setMap(map);
|
|
@@ -91,11 +93,12 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
91
93
|
asset.setCode(result.css);
|
|
92
94
|
return [asset];
|
|
93
95
|
}
|
|
94
|
-
});
|
|
96
|
+
}); // @ts-expect-error TS7031
|
|
95
97
|
function urlPlugin({
|
|
96
98
|
asset
|
|
97
99
|
}) {
|
|
98
100
|
return {
|
|
101
|
+
// @ts-expect-error TS2304
|
|
99
102
|
install(less, pluginManager) {
|
|
100
103
|
// This is a hack; no such interface exists, even conceptually, in Less.
|
|
101
104
|
|
|
@@ -110,13 +113,13 @@ function urlPlugin({
|
|
|
110
113
|
return node;
|
|
111
114
|
}
|
|
112
115
|
});
|
|
113
|
-
|
|
114
|
-
// $FlowFixMe[method-unbinding]
|
|
115
116
|
visitor.run = visitor.visit;
|
|
116
117
|
pluginManager.addVisitor(visitor);
|
|
117
118
|
}
|
|
118
119
|
};
|
|
119
120
|
}
|
|
121
|
+
|
|
122
|
+
// @ts-expect-error TS7031
|
|
120
123
|
function resolvePathPlugin({
|
|
121
124
|
asset,
|
|
122
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
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/transformer-less",
|
|
3
|
-
"version": "2.14.5-canary.
|
|
3
|
+
"version": "2.14.5-canary.139+d2fd84977",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -9,16 +9,20 @@
|
|
|
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.
|
|
12
|
+
"main": "./lib/LessTransformer.js",
|
|
13
|
+
"source": "./src/LessTransformer.ts",
|
|
14
|
+
"types": "./lib/LessTransformer.d.ts",
|
|
14
15
|
"engines": {
|
|
15
16
|
"node": ">= 16.0.0"
|
|
16
17
|
},
|
|
17
18
|
"dependencies": {
|
|
18
|
-
"@atlaspack/plugin": "2.14.5-canary.
|
|
19
|
+
"@atlaspack/plugin": "2.14.5-canary.139+d2fd84977",
|
|
19
20
|
"@parcel/source-map": "^2.1.1",
|
|
20
21
|
"less": "^4.1.1"
|
|
21
22
|
},
|
|
22
23
|
"type": "commonjs",
|
|
23
|
-
"
|
|
24
|
-
|
|
24
|
+
"scripts": {
|
|
25
|
+
"check-ts": "tsc --emitDeclarationOnly --rootDir src"
|
|
26
|
+
},
|
|
27
|
+
"gitHead": "d2fd849770fe6305e9c694bd97b1bd905abd9d94"
|
|
28
|
+
}
|
|
@@ -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
|
|
18
|
+
export default new Transformer({
|
|
21
19
|
loadConfig({config}) {
|
|
22
20
|
return load({config});
|
|
23
21
|
},
|
|
@@ -29,7 +27,6 @@ export default (new Transformer({
|
|
|
29
27
|
let code = await asset.getCode();
|
|
30
28
|
let result;
|
|
31
29
|
try {
|
|
32
|
-
// $FlowFixMe
|
|
33
30
|
let lessConfig: LessConfig = config ? {...config.config} : {};
|
|
34
31
|
|
|
35
32
|
if (asset.env.sourceMap) {
|
|
@@ -44,7 +41,7 @@ export default (new Transformer({
|
|
|
44
41
|
];
|
|
45
42
|
|
|
46
43
|
result = await less.render(code, lessConfig);
|
|
47
|
-
} catch (err) {
|
|
44
|
+
} catch (err: any) {
|
|
48
45
|
// For the error reporter
|
|
49
46
|
err.fileName = err.filename;
|
|
50
47
|
err.loc = {
|
|
@@ -59,6 +56,7 @@ export default (new Transformer({
|
|
|
59
56
|
let rawMap = JSON.parse(result.map);
|
|
60
57
|
map.addVLQMap({
|
|
61
58
|
...rawMap,
|
|
59
|
+
// @ts-expect-error TS7006
|
|
62
60
|
sources: rawMap.sources.map((s) =>
|
|
63
61
|
path.relative(options.projectRoot, s),
|
|
64
62
|
),
|
|
@@ -70,18 +68,22 @@ export default (new Transformer({
|
|
|
70
68
|
|
|
71
69
|
return [asset];
|
|
72
70
|
},
|
|
73
|
-
})
|
|
71
|
+
}) as Transformer<unknown>;
|
|
74
72
|
|
|
73
|
+
// @ts-expect-error TS7031
|
|
75
74
|
function urlPlugin({asset}) {
|
|
76
75
|
return {
|
|
77
|
-
|
|
76
|
+
// @ts-expect-error TS2304
|
|
77
|
+
install(less: Less, pluginManager: any) {
|
|
78
78
|
// This is a hack; no such interface exists, even conceptually, in Less.
|
|
79
|
-
type LessNodeWithValue =
|
|
79
|
+
type LessNodeWithValue = React.ReactNode & {
|
|
80
|
+
value: any;
|
|
81
|
+
};
|
|
80
82
|
|
|
81
83
|
const visitor = new less.visitors.Visitor({
|
|
82
|
-
visitUrl(node) {
|
|
83
|
-
const valueNode =
|
|
84
|
-
const stringValue =
|
|
84
|
+
visitUrl(node: any) {
|
|
85
|
+
const valueNode = node.value as LessNodeWithValue;
|
|
86
|
+
const stringValue = valueNode.value as string;
|
|
85
87
|
if (
|
|
86
88
|
!stringValue.startsWith('#') // IE's `behavior: url(#default#VML)`)
|
|
87
89
|
) {
|
|
@@ -91,16 +93,16 @@ function urlPlugin({asset}) {
|
|
|
91
93
|
},
|
|
92
94
|
});
|
|
93
95
|
|
|
94
|
-
// $FlowFixMe[method-unbinding]
|
|
95
96
|
visitor.run = visitor.visit;
|
|
96
97
|
pluginManager.addVisitor(visitor);
|
|
97
98
|
},
|
|
98
99
|
};
|
|
99
100
|
}
|
|
100
101
|
|
|
102
|
+
// @ts-expect-error TS7031
|
|
101
103
|
function resolvePathPlugin({asset, resolve}) {
|
|
102
104
|
return {
|
|
103
|
-
install(less, pluginManager) {
|
|
105
|
+
install(less: any, pluginManager: any) {
|
|
104
106
|
class LessFileManager extends less.FileManager {
|
|
105
107
|
supports() {
|
|
106
108
|
return true;
|
|
@@ -110,7 +112,7 @@ function resolvePathPlugin({asset, resolve}) {
|
|
|
110
112
|
return false;
|
|
111
113
|
}
|
|
112
114
|
|
|
113
|
-
async loadFile(rawFilename, currentDirectory, options) {
|
|
115
|
+
async loadFile(rawFilename: any, currentDirectory: any, options: any) {
|
|
114
116
|
let filename = rawFilename;
|
|
115
117
|
|
|
116
118
|
if (WEBPACK_ALIAS_RE.test(filename)) {
|
|
@@ -147,7 +149,7 @@ function resolvePathPlugin({asset, resolve}) {
|
|
|
147
149
|
try {
|
|
148
150
|
contents = await asset.fs.readFile(filePath, 'utf8');
|
|
149
151
|
break outer;
|
|
150
|
-
} catch (err) {
|
|
152
|
+
} catch (err: any) {
|
|
151
153
|
asset.invalidateOnFileCreate({filePath});
|
|
152
154
|
}
|
|
153
155
|
}
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import type {Config} from '@atlaspack/types';
|
|
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