@atlaspack/transformer-posthtml 2.14.5-canary.18 → 2.14.5-canary.181
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 +190 -0
- package/lib/PostHTMLTransformer.js +17 -2
- package/lib/loadPlugins.js +5 -2
- package/lib/types/PostHTMLTransformer.d.ts +3 -0
- package/lib/types/loadPlugins.d.ts +4 -0
- package/package.json +11 -6
- package/src/{PostHTMLTransformer.js → PostHTMLTransformer.ts} +15 -6
- package/src/{loadPlugins.js → loadPlugins.ts} +15 -9
- package/tsconfig.json +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,195 @@
|
|
|
1
1
|
# @atlaspack/transformer-posthtml
|
|
2
2
|
|
|
3
|
+
## 2.14.29
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies []:
|
|
8
|
+
- @atlaspack/utils@2.19.1
|
|
9
|
+
- @atlaspack/plugin@2.14.29
|
|
10
|
+
|
|
11
|
+
## 2.14.28
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [[`f0349a6`](https://github.com/atlassian-labs/atlaspack/commit/f0349a6b9b04755088f121095ca6301a2ada3767)]:
|
|
16
|
+
- @atlaspack/utils@2.19.0
|
|
17
|
+
- @atlaspack/plugin@2.14.28
|
|
18
|
+
|
|
19
|
+
## 2.14.27
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies []:
|
|
24
|
+
- @atlaspack/utils@2.18.4
|
|
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), [`889c65c`](https://github.com/atlassian-labs/atlaspack/commit/889c65cd25b811045e26a117e7404f694dde77a2)]:
|
|
34
|
+
- @atlaspack/plugin@2.14.26
|
|
35
|
+
- @atlaspack/utils@2.18.3
|
|
36
|
+
|
|
37
|
+
## 2.14.25
|
|
38
|
+
|
|
39
|
+
### Patch Changes
|
|
40
|
+
|
|
41
|
+
- Updated dependencies []:
|
|
42
|
+
- @atlaspack/utils@2.18.2
|
|
43
|
+
- @atlaspack/plugin@2.14.25
|
|
44
|
+
|
|
45
|
+
## 2.14.24
|
|
46
|
+
|
|
47
|
+
### Patch Changes
|
|
48
|
+
|
|
49
|
+
- Updated dependencies []:
|
|
50
|
+
- @atlaspack/utils@2.18.1
|
|
51
|
+
- @atlaspack/plugin@2.14.24
|
|
52
|
+
|
|
53
|
+
## 2.14.23
|
|
54
|
+
|
|
55
|
+
### Patch Changes
|
|
56
|
+
|
|
57
|
+
- Updated dependencies [[`23d561e`](https://github.com/atlassian-labs/atlaspack/commit/23d561e51e68b0c38fd1ff4e4fb173e5e7b01cf2)]:
|
|
58
|
+
- @atlaspack/utils@2.18.0
|
|
59
|
+
- @atlaspack/plugin@2.14.23
|
|
60
|
+
|
|
61
|
+
## 2.14.22
|
|
62
|
+
|
|
63
|
+
### Patch Changes
|
|
64
|
+
|
|
65
|
+
- [#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
|
|
66
|
+
|
|
67
|
+
- Updated dependencies [[`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94)]:
|
|
68
|
+
- @atlaspack/plugin@2.14.22
|
|
69
|
+
- @atlaspack/utils@2.17.4
|
|
70
|
+
|
|
71
|
+
## 2.14.21
|
|
72
|
+
|
|
73
|
+
### Patch Changes
|
|
74
|
+
|
|
75
|
+
- Updated dependencies []:
|
|
76
|
+
- @atlaspack/utils@2.17.3
|
|
77
|
+
- @atlaspack/plugin@2.14.21
|
|
78
|
+
|
|
79
|
+
## 2.14.20
|
|
80
|
+
|
|
81
|
+
### Patch Changes
|
|
82
|
+
|
|
83
|
+
- [#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
|
|
84
|
+
|
|
85
|
+
- Updated dependencies [[`daaa768`](https://github.com/atlassian-labs/atlaspack/commit/daaa7688786772d7e3713b71c5bba6b89ec704aa)]:
|
|
86
|
+
- @atlaspack/plugin@2.14.20
|
|
87
|
+
- @atlaspack/utils@2.17.2
|
|
88
|
+
|
|
89
|
+
## 2.14.19
|
|
90
|
+
|
|
91
|
+
### Patch Changes
|
|
92
|
+
|
|
93
|
+
- Updated dependencies []:
|
|
94
|
+
- @atlaspack/utils@2.17.1
|
|
95
|
+
- @atlaspack/plugin@2.14.19
|
|
96
|
+
|
|
97
|
+
## 2.14.18
|
|
98
|
+
|
|
99
|
+
### Patch Changes
|
|
100
|
+
|
|
101
|
+
- Updated dependencies [[`dbb4072`](https://github.com/atlassian-labs/atlaspack/commit/dbb40721ebeb45990a14ba04e6b44e7f836fb32d), [`de23e0c`](https://github.com/atlassian-labs/atlaspack/commit/de23e0ce49d5504fe3947ac26640a3d951087da3), [`18a57cf`](https://github.com/atlassian-labs/atlaspack/commit/18a57cf8a4789b2de5ad8e2676f317a26cc91417), [`a5ed1b4`](https://github.com/atlassian-labs/atlaspack/commit/a5ed1b414498560f393ff491af4da25b6e8dde56)]:
|
|
102
|
+
- @atlaspack/utils@2.17.0
|
|
103
|
+
- @atlaspack/plugin@2.14.18
|
|
104
|
+
|
|
105
|
+
## 2.14.17
|
|
106
|
+
|
|
107
|
+
### Patch Changes
|
|
108
|
+
|
|
109
|
+
- Updated dependencies []:
|
|
110
|
+
- @atlaspack/utils@2.16.1
|
|
111
|
+
- @atlaspack/plugin@2.14.17
|
|
112
|
+
|
|
113
|
+
## 2.14.16
|
|
114
|
+
|
|
115
|
+
### Patch Changes
|
|
116
|
+
|
|
117
|
+
- Updated dependencies [[`30ee2cf`](https://github.com/atlassian-labs/atlaspack/commit/30ee2cfcd34cf2646ded0eda13fdb80a2a5de529)]:
|
|
118
|
+
- @atlaspack/utils@2.16.0
|
|
119
|
+
- @atlaspack/plugin@2.14.16
|
|
120
|
+
|
|
121
|
+
## 2.14.15
|
|
122
|
+
|
|
123
|
+
### Patch Changes
|
|
124
|
+
|
|
125
|
+
- Updated dependencies []:
|
|
126
|
+
- @atlaspack/utils@2.15.3
|
|
127
|
+
- @atlaspack/plugin@2.14.15
|
|
128
|
+
|
|
129
|
+
## 2.14.14
|
|
130
|
+
|
|
131
|
+
### Patch Changes
|
|
132
|
+
|
|
133
|
+
- Updated dependencies []:
|
|
134
|
+
- @atlaspack/utils@2.15.2
|
|
135
|
+
- @atlaspack/plugin@2.14.14
|
|
136
|
+
|
|
137
|
+
## 2.14.13
|
|
138
|
+
|
|
139
|
+
### Patch Changes
|
|
140
|
+
|
|
141
|
+
- Updated dependencies []:
|
|
142
|
+
- @atlaspack/utils@2.15.1
|
|
143
|
+
- @atlaspack/plugin@2.14.13
|
|
144
|
+
|
|
145
|
+
## 2.14.12
|
|
146
|
+
|
|
147
|
+
### Patch Changes
|
|
148
|
+
|
|
149
|
+
- Updated dependencies [[`e39c6cf`](https://github.com/atlassian-labs/atlaspack/commit/e39c6cf05f7e95ce5420dbcea66f401b1cbd397c)]:
|
|
150
|
+
- @atlaspack/utils@2.15.0
|
|
151
|
+
- @atlaspack/plugin@2.14.12
|
|
152
|
+
|
|
153
|
+
## 2.14.11
|
|
154
|
+
|
|
155
|
+
### Patch Changes
|
|
156
|
+
|
|
157
|
+
- Updated dependencies []:
|
|
158
|
+
- @atlaspack/utils@2.14.11
|
|
159
|
+
- @atlaspack/plugin@2.14.11
|
|
160
|
+
|
|
161
|
+
## 2.14.10
|
|
162
|
+
|
|
163
|
+
### Patch Changes
|
|
164
|
+
|
|
165
|
+
- Updated dependencies []:
|
|
166
|
+
- @atlaspack/plugin@2.14.10
|
|
167
|
+
- @atlaspack/utils@2.14.10
|
|
168
|
+
|
|
169
|
+
## 2.14.9
|
|
170
|
+
|
|
171
|
+
### Patch Changes
|
|
172
|
+
|
|
173
|
+
- Updated dependencies []:
|
|
174
|
+
- @atlaspack/utils@2.14.9
|
|
175
|
+
- @atlaspack/plugin@2.14.9
|
|
176
|
+
|
|
177
|
+
## 2.14.8
|
|
178
|
+
|
|
179
|
+
### Patch Changes
|
|
180
|
+
|
|
181
|
+
- Updated dependencies []:
|
|
182
|
+
- @atlaspack/utils@2.14.8
|
|
183
|
+
- @atlaspack/plugin@2.14.8
|
|
184
|
+
|
|
185
|
+
## 2.14.7
|
|
186
|
+
|
|
187
|
+
### Patch Changes
|
|
188
|
+
|
|
189
|
+
- Updated dependencies []:
|
|
190
|
+
- @atlaspack/utils@2.14.7
|
|
191
|
+
- @atlaspack/plugin@2.14.7
|
|
192
|
+
|
|
3
193
|
## 2.14.6
|
|
4
194
|
|
|
5
195
|
### Patch Changes
|
|
@@ -78,10 +78,17 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
// Load plugins. This must be done before adding dev dependencies so we auto install.
|
|
81
|
-
let plugins = await (0, _loadPlugins.default)(
|
|
81
|
+
let plugins = await (0, _loadPlugins.default)(
|
|
82
|
+
// @ts-expect-error TS18046
|
|
83
|
+
configFile.contents.plugins, config.searchPath, options);
|
|
82
84
|
|
|
83
85
|
// Now add dev dependencies so we invalidate when they change.
|
|
84
|
-
|
|
86
|
+
// @ts-expect-error TS18046
|
|
87
|
+
let pluginArray = Array.isArray(configFile.contents.plugins) ?
|
|
88
|
+
// @ts-expect-error TS18046
|
|
89
|
+
configFile.contents.plugins :
|
|
90
|
+
// @ts-expect-error TS18046
|
|
91
|
+
Object.keys(configFile.contents.plugins);
|
|
85
92
|
for (let p of pluginArray) {
|
|
86
93
|
if (typeof p === 'string') {
|
|
87
94
|
config.addDevDependency({
|
|
@@ -90,10 +97,14 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
90
97
|
});
|
|
91
98
|
}
|
|
92
99
|
}
|
|
100
|
+
|
|
101
|
+
// @ts-expect-error TS18046
|
|
93
102
|
configFile.contents.plugins = plugins;
|
|
94
103
|
|
|
95
104
|
// tells posthtml that we have already called parse
|
|
105
|
+
// @ts-expect-error TS18046
|
|
96
106
|
configFile.contents.skipParse = true;
|
|
107
|
+
// @ts-expect-error TS18046
|
|
97
108
|
delete configFile.contents.render;
|
|
98
109
|
return configFile.contents;
|
|
99
110
|
}
|
|
@@ -129,11 +140,14 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
129
140
|
return [asset];
|
|
130
141
|
}
|
|
131
142
|
let ast = (0, _nullthrows().default)(await asset.getAST());
|
|
143
|
+
// @ts-expect-error TS2339
|
|
132
144
|
let res = await (0, _posthtml().default)(config.plugins).process(ast.program, {
|
|
133
145
|
...config,
|
|
146
|
+
// @ts-expect-error TS2353
|
|
134
147
|
plugins: config.plugins
|
|
135
148
|
});
|
|
136
149
|
if (res.messages) {
|
|
150
|
+
// @ts-expect-error TS2339
|
|
137
151
|
for (let {
|
|
138
152
|
type,
|
|
139
153
|
file: filePath
|
|
@@ -157,6 +171,7 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
157
171
|
}) {
|
|
158
172
|
return {
|
|
159
173
|
content: (0, _posthtmlRender().render)(ast.program, {
|
|
174
|
+
// @ts-expect-error TS2322
|
|
160
175
|
closingSingleTag: asset.type === 'xhtml' ? 'slash' : undefined
|
|
161
176
|
})
|
|
162
177
|
};
|
package/lib/loadPlugins.js
CHANGED
|
@@ -8,13 +8,16 @@ async function loadExternalPlugins(plugins, relative, options) {
|
|
|
8
8
|
if (Array.isArray(plugins)) {
|
|
9
9
|
return Promise.all(plugins.map(p => loadPlugin(p, relative, null, options.packageManager, options.shouldAutoInstall)).filter(Boolean));
|
|
10
10
|
} else if (typeof plugins === 'object') {
|
|
11
|
-
let
|
|
11
|
+
let _plugins = plugins;
|
|
12
|
+
let mapPlugins = await Promise.all(Object.keys(plugins).map(p => loadPlugin(p, relative, _plugins[p], options.packageManager, options.shouldAutoInstall)));
|
|
12
13
|
return mapPlugins.filter(Boolean);
|
|
13
14
|
} else {
|
|
14
15
|
return [];
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
|
-
async function loadPlugin(pluginArg, relative, options = {}, packageManager, shouldAutoInstall
|
|
18
|
+
async function loadPlugin(pluginArg, relative, options = {}, packageManager, shouldAutoInstall
|
|
19
|
+
// @ts-expect-error TS1064
|
|
20
|
+
) {
|
|
18
21
|
if (typeof pluginArg !== 'string') {
|
|
19
22
|
return pluginArg;
|
|
20
23
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/transformer-posthtml",
|
|
3
|
-
"version": "2.14.5-canary.
|
|
3
|
+
"version": "2.14.5-canary.181+0211c6986",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -9,14 +9,15 @@
|
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "https://github.com/atlassian-labs/atlaspack.git"
|
|
11
11
|
},
|
|
12
|
-
"main": "lib/PostHTMLTransformer.js",
|
|
13
|
-
"source": "src/PostHTMLTransformer.
|
|
12
|
+
"main": "./lib/PostHTMLTransformer.js",
|
|
13
|
+
"source": "./src/PostHTMLTransformer.ts",
|
|
14
|
+
"types": "./lib/types/PostHTMLTransformer.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/utils": "2.14.5-canary.
|
|
19
|
+
"@atlaspack/plugin": "2.14.5-canary.181+0211c6986",
|
|
20
|
+
"@atlaspack/utils": "2.14.5-canary.181+0211c6986",
|
|
20
21
|
"nullthrows": "^1.1.1",
|
|
21
22
|
"posthtml": "^0.16.5",
|
|
22
23
|
"posthtml-parser": "^0.10.1",
|
|
@@ -24,5 +25,9 @@
|
|
|
24
25
|
"semver": "^7.5.2"
|
|
25
26
|
},
|
|
26
27
|
"type": "commonjs",
|
|
27
|
-
"
|
|
28
|
+
"scripts": {
|
|
29
|
+
"check-ts": "tsc --emitDeclarationOnly --rootDir src",
|
|
30
|
+
"build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
|
|
31
|
+
},
|
|
32
|
+
"gitHead": "0211c698666b6e8282aff005d286b29ad00fd31f"
|
|
28
33
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
1
|
import {Transformer} from '@atlaspack/plugin';
|
|
4
2
|
|
|
5
3
|
import path from 'path';
|
|
@@ -10,7 +8,7 @@ import nullthrows from 'nullthrows';
|
|
|
10
8
|
import semver from 'semver';
|
|
11
9
|
import loadPlugins from './loadPlugins';
|
|
12
10
|
|
|
13
|
-
export default
|
|
11
|
+
export default new Transformer({
|
|
14
12
|
async loadConfig({config, options, logger}) {
|
|
15
13
|
if (!config.isSource) {
|
|
16
14
|
return;
|
|
@@ -44,15 +42,19 @@ export default (new Transformer({
|
|
|
44
42
|
|
|
45
43
|
// Load plugins. This must be done before adding dev dependencies so we auto install.
|
|
46
44
|
let plugins = await loadPlugins(
|
|
45
|
+
// @ts-expect-error TS18046
|
|
47
46
|
configFile.contents.plugins,
|
|
48
47
|
config.searchPath,
|
|
49
48
|
options,
|
|
50
49
|
);
|
|
51
50
|
|
|
52
51
|
// Now add dev dependencies so we invalidate when they change.
|
|
52
|
+
// @ts-expect-error TS18046
|
|
53
53
|
let pluginArray = Array.isArray(configFile.contents.plugins)
|
|
54
|
-
?
|
|
55
|
-
|
|
54
|
+
? // @ts-expect-error TS18046
|
|
55
|
+
configFile.contents.plugins
|
|
56
|
+
: // @ts-expect-error TS18046
|
|
57
|
+
Object.keys(configFile.contents.plugins);
|
|
56
58
|
for (let p of pluginArray) {
|
|
57
59
|
if (typeof p === 'string') {
|
|
58
60
|
config.addDevDependency({
|
|
@@ -62,10 +64,13 @@ export default (new Transformer({
|
|
|
62
64
|
}
|
|
63
65
|
}
|
|
64
66
|
|
|
67
|
+
// @ts-expect-error TS18046
|
|
65
68
|
configFile.contents.plugins = plugins;
|
|
66
69
|
|
|
67
70
|
// tells posthtml that we have already called parse
|
|
71
|
+
// @ts-expect-error TS18046
|
|
68
72
|
configFile.contents.skipParse = true;
|
|
73
|
+
// @ts-expect-error TS18046
|
|
69
74
|
delete configFile.contents.render;
|
|
70
75
|
|
|
71
76
|
return configFile.contents;
|
|
@@ -99,12 +104,15 @@ export default (new Transformer({
|
|
|
99
104
|
}
|
|
100
105
|
|
|
101
106
|
let ast = nullthrows(await asset.getAST());
|
|
107
|
+
// @ts-expect-error TS2339
|
|
102
108
|
let res = await posthtml(config.plugins).process(ast.program, {
|
|
103
109
|
...config,
|
|
110
|
+
// @ts-expect-error TS2353
|
|
104
111
|
plugins: config.plugins,
|
|
105
112
|
});
|
|
106
113
|
|
|
107
114
|
if (res.messages) {
|
|
115
|
+
// @ts-expect-error TS2339
|
|
108
116
|
for (let {type, file: filePath} of res.messages) {
|
|
109
117
|
if (type === 'dependency') {
|
|
110
118
|
asset.invalidateOnFileChange(filePath);
|
|
@@ -124,8 +132,9 @@ export default (new Transformer({
|
|
|
124
132
|
generate({ast, asset}) {
|
|
125
133
|
return {
|
|
126
134
|
content: render(ast.program, {
|
|
135
|
+
// @ts-expect-error TS2322
|
|
127
136
|
closingSingleTag: asset.type === 'xhtml' ? 'slash' : undefined,
|
|
128
137
|
}),
|
|
129
138
|
};
|
|
130
139
|
},
|
|
131
|
-
})
|
|
140
|
+
}) as Transformer<unknown>;
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import type {
|
|
2
|
+
FilePath,
|
|
3
|
+
PluginOptions,
|
|
4
|
+
PackageManager,
|
|
5
|
+
} from '@atlaspack/types-internal';
|
|
5
6
|
|
|
6
7
|
export default async function loadExternalPlugins(
|
|
7
|
-
plugins:
|
|
8
|
+
plugins:
|
|
9
|
+
| Array<string>
|
|
10
|
+
| {
|
|
11
|
+
readonly [pluginName: string]: unknown;
|
|
12
|
+
},
|
|
8
13
|
relative: FilePath,
|
|
9
14
|
options: PluginOptions,
|
|
10
|
-
): Promise<Array<
|
|
15
|
+
): Promise<Array<unknown>> {
|
|
11
16
|
if (Array.isArray(plugins)) {
|
|
12
17
|
return Promise.all(
|
|
13
18
|
plugins
|
|
@@ -42,12 +47,13 @@ export default async function loadExternalPlugins(
|
|
|
42
47
|
}
|
|
43
48
|
|
|
44
49
|
async function loadPlugin(
|
|
45
|
-
pluginArg: string |
|
|
50
|
+
pluginArg: string | any,
|
|
46
51
|
relative: FilePath,
|
|
47
|
-
options:
|
|
52
|
+
options: unknown | null | undefined = {},
|
|
48
53
|
packageManager: PackageManager,
|
|
49
54
|
shouldAutoInstall: boolean,
|
|
50
|
-
|
|
55
|
+
// @ts-expect-error TS1064
|
|
56
|
+
): unknown {
|
|
51
57
|
if (typeof pluginArg !== 'string') {
|
|
52
58
|
return pluginArg;
|
|
53
59
|
}
|
package/tsconfig.json
ADDED