@putout/engine-loader 11.5.0 → 11.6.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/load/load.js +14 -1
- package/package.json +2 -1
package/lib/load/load.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const process = require('process');
|
|
3
4
|
const {createRequire} = require('module');
|
|
4
5
|
|
|
5
6
|
const tryCatch = require('try-catch');
|
|
6
7
|
const once = require('once');
|
|
8
|
+
const {assign} = Object;
|
|
7
9
|
|
|
8
10
|
const bigFirst = (a) => `${a[0].toUpperCase()}${a.slice(1)}`;
|
|
9
11
|
|
|
@@ -13,7 +15,18 @@ const load = (type) => ({name, namespace}) => {
|
|
|
13
15
|
if (!pluginPath)
|
|
14
16
|
throw Error(`${bigFirst(type)} "${namespace}-${type}-${name}" could not be found!`);
|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
const [error, result] = tryCatch(customRequire, pluginPath);
|
|
19
|
+
|
|
20
|
+
if (error?.code === 'ERR_REQUIRE_ESM')
|
|
21
|
+
assign(error, {
|
|
22
|
+
message: `☝️ Looks like '${name}' is ESM, use 'await putoutAsync()' instead`,
|
|
23
|
+
name,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
if (error)
|
|
27
|
+
throw error;
|
|
28
|
+
|
|
29
|
+
return result;
|
|
17
30
|
};
|
|
18
31
|
|
|
19
32
|
module.exports.loadPlugin = load('plugin');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/engine-loader",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.6.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "load plugins and prepare them to run",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@putout/formatter-progress": "*",
|
|
44
|
+
"@putout/plugin-apply-nullish-coalescing": "*",
|
|
44
45
|
"@putout/plugin-convert-commonjs-to-esm": "*",
|
|
45
46
|
"@putout/plugin-remove-unused-variables": "*",
|
|
46
47
|
"@putout/processor-javascript": "*",
|