@parcel/transformer-posthtml 2.8.4-nightly.0 → 2.9.0
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 +9 -46
- package/lib/loadPlugins.js +0 -3
- package/package.json +5 -5
|
@@ -4,81 +4,57 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
function _plugin() {
|
|
9
8
|
const data = require("@parcel/plugin");
|
|
10
|
-
|
|
11
9
|
_plugin = function () {
|
|
12
10
|
return data;
|
|
13
11
|
};
|
|
14
|
-
|
|
15
12
|
return data;
|
|
16
13
|
}
|
|
17
|
-
|
|
18
14
|
function _path() {
|
|
19
15
|
const data = _interopRequireDefault(require("path"));
|
|
20
|
-
|
|
21
16
|
_path = function () {
|
|
22
17
|
return data;
|
|
23
18
|
};
|
|
24
|
-
|
|
25
19
|
return data;
|
|
26
20
|
}
|
|
27
|
-
|
|
28
21
|
function _posthtml() {
|
|
29
22
|
const data = _interopRequireDefault(require("posthtml"));
|
|
30
|
-
|
|
31
23
|
_posthtml = function () {
|
|
32
24
|
return data;
|
|
33
25
|
};
|
|
34
|
-
|
|
35
26
|
return data;
|
|
36
27
|
}
|
|
37
|
-
|
|
38
28
|
function _posthtmlParser() {
|
|
39
29
|
const data = require("posthtml-parser");
|
|
40
|
-
|
|
41
30
|
_posthtmlParser = function () {
|
|
42
31
|
return data;
|
|
43
32
|
};
|
|
44
|
-
|
|
45
33
|
return data;
|
|
46
34
|
}
|
|
47
|
-
|
|
48
35
|
function _posthtmlRender() {
|
|
49
36
|
const data = require("posthtml-render");
|
|
50
|
-
|
|
51
37
|
_posthtmlRender = function () {
|
|
52
38
|
return data;
|
|
53
39
|
};
|
|
54
|
-
|
|
55
40
|
return data;
|
|
56
41
|
}
|
|
57
|
-
|
|
58
42
|
function _nullthrows() {
|
|
59
43
|
const data = _interopRequireDefault(require("nullthrows"));
|
|
60
|
-
|
|
61
44
|
_nullthrows = function () {
|
|
62
45
|
return data;
|
|
63
46
|
};
|
|
64
|
-
|
|
65
47
|
return data;
|
|
66
48
|
}
|
|
67
|
-
|
|
68
49
|
function _semver() {
|
|
69
50
|
const data = _interopRequireDefault(require("semver"));
|
|
70
|
-
|
|
71
51
|
_semver = function () {
|
|
72
52
|
return data;
|
|
73
53
|
};
|
|
74
|
-
|
|
75
54
|
return data;
|
|
76
55
|
}
|
|
77
|
-
|
|
78
56
|
var _loadPlugins = _interopRequireDefault(require("./loadPlugins"));
|
|
79
|
-
|
|
80
57
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
81
|
-
|
|
82
58
|
var _default = new (_plugin().Transformer)({
|
|
83
59
|
async loadConfig({
|
|
84
60
|
config,
|
|
@@ -88,27 +64,24 @@ var _default = new (_plugin().Transformer)({
|
|
|
88
64
|
if (!config.isSource) {
|
|
89
65
|
return;
|
|
90
66
|
}
|
|
91
|
-
|
|
92
67
|
let configFile = await config.getConfig(['.posthtmlrc', '.posthtmlrc.js', '.posthtmlrc.cjs', '.posthtmlrc.mjs', 'posthtml.config.js', 'posthtml.config.cjs', 'posthtml.config.mjs'], {
|
|
93
68
|
packageKey: 'posthtml'
|
|
94
69
|
});
|
|
95
|
-
|
|
96
70
|
if (configFile) {
|
|
97
71
|
let isJavascript = _path().default.extname(configFile.filePath).endsWith('js');
|
|
98
|
-
|
|
99
72
|
if (isJavascript) {
|
|
100
73
|
// We have to invalidate on startup in case the config is non-deterministic,
|
|
101
74
|
// e.g. using unknown environment variables, reading from the filesystem, etc.
|
|
102
75
|
logger.warn({
|
|
103
76
|
message: 'WARNING: Using a JavaScript PostHTML config file means losing out on caching features of Parcel. Use a .posthtmlrc (JSON) file whenever possible.'
|
|
104
77
|
});
|
|
105
|
-
}
|
|
106
|
-
|
|
78
|
+
}
|
|
107
79
|
|
|
108
|
-
|
|
80
|
+
// Load plugins. This must be done before adding dev dependencies so we auto install.
|
|
81
|
+
let plugins = await (0, _loadPlugins.default)(configFile.contents.plugins, config.searchPath, options);
|
|
109
82
|
|
|
83
|
+
// Now add dev dependencies so we invalidate when they change.
|
|
110
84
|
let pluginArray = Array.isArray(configFile.contents.plugins) ? configFile.contents.plugins : Object.keys(configFile.contents.plugins);
|
|
111
|
-
|
|
112
85
|
for (let p of pluginArray) {
|
|
113
86
|
if (typeof p === 'string') {
|
|
114
87
|
config.addDevDependency({
|
|
@@ -117,21 +90,19 @@ var _default = new (_plugin().Transformer)({
|
|
|
117
90
|
});
|
|
118
91
|
}
|
|
119
92
|
}
|
|
93
|
+
configFile.contents.plugins = plugins;
|
|
120
94
|
|
|
121
|
-
|
|
122
|
-
|
|
95
|
+
// tells posthtml that we have already called parse
|
|
123
96
|
configFile.contents.skipParse = true;
|
|
124
97
|
delete configFile.contents.render;
|
|
125
98
|
return configFile.contents;
|
|
126
99
|
}
|
|
127
100
|
},
|
|
128
|
-
|
|
129
101
|
canReuseAST({
|
|
130
102
|
ast
|
|
131
103
|
}) {
|
|
132
104
|
return ast.type === 'posthtml' && _semver().default.satisfies(ast.version, '^0.4.0');
|
|
133
105
|
},
|
|
134
|
-
|
|
135
106
|
async parse({
|
|
136
107
|
asset,
|
|
137
108
|
config
|
|
@@ -140,7 +111,6 @@ var _default = new (_plugin().Transformer)({
|
|
|
140
111
|
if (!config) {
|
|
141
112
|
return;
|
|
142
113
|
}
|
|
143
|
-
|
|
144
114
|
return {
|
|
145
115
|
type: 'posthtml',
|
|
146
116
|
version: '0.4.1',
|
|
@@ -151,7 +121,6 @@ var _default = new (_plugin().Transformer)({
|
|
|
151
121
|
})
|
|
152
122
|
};
|
|
153
123
|
},
|
|
154
|
-
|
|
155
124
|
async transform({
|
|
156
125
|
asset,
|
|
157
126
|
config
|
|
@@ -159,12 +128,11 @@ var _default = new (_plugin().Transformer)({
|
|
|
159
128
|
if (!config) {
|
|
160
129
|
return [asset];
|
|
161
130
|
}
|
|
162
|
-
|
|
163
131
|
let ast = (0, _nullthrows().default)(await asset.getAST());
|
|
164
|
-
let res = await (0, _posthtml().default)(config.plugins).process(ast.program, {
|
|
132
|
+
let res = await (0, _posthtml().default)(config.plugins).process(ast.program, {
|
|
133
|
+
...config,
|
|
165
134
|
plugins: config.plugins
|
|
166
135
|
});
|
|
167
|
-
|
|
168
136
|
if (res.messages) {
|
|
169
137
|
await Promise.all(res.messages.map(({
|
|
170
138
|
type,
|
|
@@ -173,20 +141,17 @@ var _default = new (_plugin().Transformer)({
|
|
|
173
141
|
if (type === 'dependency') {
|
|
174
142
|
return asset.invalidateOnFileChange(filePath);
|
|
175
143
|
}
|
|
176
|
-
|
|
177
144
|
return Promise.resolve();
|
|
178
145
|
}));
|
|
179
146
|
}
|
|
180
|
-
|
|
181
147
|
asset.setAST({
|
|
182
148
|
type: 'posthtml',
|
|
183
149
|
version: '0.4.1',
|
|
184
150
|
program: JSON.parse(JSON.stringify(res.tree)) // posthtml adds functions to the AST that are not serializable
|
|
185
|
-
|
|
186
151
|
});
|
|
152
|
+
|
|
187
153
|
return [asset];
|
|
188
154
|
},
|
|
189
|
-
|
|
190
155
|
generate({
|
|
191
156
|
ast,
|
|
192
157
|
asset
|
|
@@ -197,7 +162,5 @@ var _default = new (_plugin().Transformer)({
|
|
|
197
162
|
})
|
|
198
163
|
};
|
|
199
164
|
}
|
|
200
|
-
|
|
201
165
|
});
|
|
202
|
-
|
|
203
166
|
exports.default = _default;
|
package/lib/loadPlugins.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = loadExternalPlugins;
|
|
7
|
-
|
|
8
7
|
async function loadExternalPlugins(plugins, relative, options) {
|
|
9
8
|
if (Array.isArray(plugins)) {
|
|
10
9
|
return Promise.all(plugins.map(p => loadPlugin(p, relative, null, options.packageManager, options.shouldAutoInstall)).filter(Boolean));
|
|
@@ -15,12 +14,10 @@ async function loadExternalPlugins(plugins, relative, options) {
|
|
|
15
14
|
return [];
|
|
16
15
|
}
|
|
17
16
|
}
|
|
18
|
-
|
|
19
17
|
async function loadPlugin(pluginArg, relative, options = {}, packageManager, shouldAutoInstall) {
|
|
20
18
|
if (typeof pluginArg !== 'string') {
|
|
21
19
|
return pluginArg;
|
|
22
20
|
}
|
|
23
|
-
|
|
24
21
|
let plugin = await packageManager.require(pluginArg, relative, {
|
|
25
22
|
shouldAutoInstall
|
|
26
23
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcel/transformer-posthtml",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.0",
|
|
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.9.0"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@parcel/plugin": "2.
|
|
24
|
-
"@parcel/utils": "2.
|
|
23
|
+
"@parcel/plugin": "2.9.0",
|
|
24
|
+
"@parcel/utils": "2.9.0",
|
|
25
25
|
"nullthrows": "^1.1.1",
|
|
26
26
|
"posthtml": "^0.16.5",
|
|
27
27
|
"posthtml-parser": "^0.10.1",
|
|
28
28
|
"posthtml-render": "^3.0.0",
|
|
29
29
|
"semver": "^5.7.1"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "dd9435be8afed35c5ffc161cf4b586fd6c78fc1f"
|
|
32
32
|
}
|