@parcel/transformer-posthtml 2.0.0-rc.0 → 2.1.1
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/PostHTMLTransformer.js +14 -6
- package/package.json +9 -9
- package/src/PostHTMLTransformer.js +11 -4
|
@@ -36,7 +36,7 @@ function _posthtml() {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
function _posthtmlParser() {
|
|
39
|
-
const data =
|
|
39
|
+
const data = require("posthtml-parser");
|
|
40
40
|
|
|
41
41
|
_posthtmlParser = function () {
|
|
42
42
|
return data;
|
|
@@ -46,7 +46,7 @@ function _posthtmlParser() {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
function _posthtmlRender() {
|
|
49
|
-
const data =
|
|
49
|
+
const data = require("posthtml-render");
|
|
50
50
|
|
|
51
51
|
_posthtmlRender = function () {
|
|
52
52
|
return data;
|
|
@@ -95,6 +95,10 @@ var _default = new (_plugin().Transformer)({
|
|
|
95
95
|
options,
|
|
96
96
|
logger
|
|
97
97
|
}) {
|
|
98
|
+
if (!config.isSource) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
98
102
|
let configFile = await config.getConfig(['.posthtmlrc', '.posthtmlrc.js', 'posthtml.config.js'], {
|
|
99
103
|
packageKey: 'posthtml'
|
|
100
104
|
});
|
|
@@ -156,9 +160,10 @@ var _default = new (_plugin().Transformer)({
|
|
|
156
160
|
return {
|
|
157
161
|
type: 'posthtml',
|
|
158
162
|
version: '0.4.1',
|
|
159
|
-
program: (0, _posthtmlParser().
|
|
163
|
+
program: (0, _posthtmlParser().parser)(await asset.getCode(), {
|
|
160
164
|
lowerCaseAttributeNames: true,
|
|
161
|
-
sourceLocations: true
|
|
165
|
+
sourceLocations: true,
|
|
166
|
+
xmlMode: asset.type === 'xhtml'
|
|
162
167
|
})
|
|
163
168
|
};
|
|
164
169
|
},
|
|
@@ -199,10 +204,13 @@ var _default = new (_plugin().Transformer)({
|
|
|
199
204
|
},
|
|
200
205
|
|
|
201
206
|
generate({
|
|
202
|
-
ast
|
|
207
|
+
ast,
|
|
208
|
+
asset
|
|
203
209
|
}) {
|
|
204
210
|
return {
|
|
205
|
-
content: (0, _posthtmlRender().
|
|
211
|
+
content: (0, _posthtmlRender().render)(ast.program, {
|
|
212
|
+
closingSingleTag: asset.type === 'xhtml' ? 'slash' : undefined
|
|
213
|
+
})
|
|
206
214
|
};
|
|
207
215
|
}
|
|
208
216
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcel/transformer-posthtml",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -17,16 +17,16 @@
|
|
|
17
17
|
"source": "src/PostHTMLTransformer.js",
|
|
18
18
|
"engines": {
|
|
19
19
|
"node": ">= 12.0.0",
|
|
20
|
-
"parcel": "^2.
|
|
20
|
+
"parcel": "^2.1.1"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@parcel/plugin": "2.
|
|
24
|
-
"@parcel/utils": "2.
|
|
23
|
+
"@parcel/plugin": "^2.1.1",
|
|
24
|
+
"@parcel/utils": "^2.1.1",
|
|
25
25
|
"nullthrows": "^1.1.1",
|
|
26
|
-
"posthtml": "^0.16.
|
|
27
|
-
"posthtml-parser": "^0.
|
|
28
|
-
"posthtml-render": "^
|
|
29
|
-
"semver": "^5.
|
|
26
|
+
"posthtml": "^0.16.5",
|
|
27
|
+
"posthtml-parser": "^0.10.1",
|
|
28
|
+
"posthtml-render": "^3.0.0",
|
|
29
|
+
"semver": "^5.7.1"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "f53ffe772a8259d94ca2937d02fde149454112f3"
|
|
32
32
|
}
|
|
@@ -4,8 +4,8 @@ import {Transformer} from '@parcel/plugin';
|
|
|
4
4
|
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import posthtml from 'posthtml';
|
|
7
|
-
import parse from 'posthtml-parser';
|
|
8
|
-
import render from 'posthtml-render';
|
|
7
|
+
import {parser as parse} from 'posthtml-parser';
|
|
8
|
+
import {render} from 'posthtml-render';
|
|
9
9
|
import nullthrows from 'nullthrows';
|
|
10
10
|
import semver from 'semver';
|
|
11
11
|
import {relativePath} from '@parcel/utils';
|
|
@@ -13,6 +13,10 @@ import loadPlugins from './loadPlugins';
|
|
|
13
13
|
|
|
14
14
|
export default (new Transformer({
|
|
15
15
|
async loadConfig({config, options, logger}) {
|
|
16
|
+
if (!config.isSource) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
16
20
|
let configFile = await config.getConfig(
|
|
17
21
|
['.posthtmlrc', '.posthtmlrc.js', 'posthtml.config.js'],
|
|
18
22
|
{
|
|
@@ -88,6 +92,7 @@ export default (new Transformer({
|
|
|
88
92
|
program: parse(await asset.getCode(), {
|
|
89
93
|
lowerCaseAttributeNames: true,
|
|
90
94
|
sourceLocations: true,
|
|
95
|
+
xmlMode: asset.type === 'xhtml',
|
|
91
96
|
}),
|
|
92
97
|
};
|
|
93
98
|
},
|
|
@@ -123,9 +128,11 @@ export default (new Transformer({
|
|
|
123
128
|
return [asset];
|
|
124
129
|
},
|
|
125
130
|
|
|
126
|
-
generate({ast}) {
|
|
131
|
+
generate({ast, asset}) {
|
|
127
132
|
return {
|
|
128
|
-
content: render(ast.program
|
|
133
|
+
content: render(ast.program, {
|
|
134
|
+
closingSingleTag: asset.type === 'xhtml' ? 'slash' : undefined,
|
|
135
|
+
}),
|
|
129
136
|
};
|
|
130
137
|
},
|
|
131
138
|
}): Transformer);
|