@putout/engine-loader 11.5.0 → 12.0.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.
Files changed (2) hide show
  1. package/lib/load/load.js +14 -1
  2. package/package.json +3 -2
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
- return customRequire(pluginPath);
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.5.0",
3
+ "version": "12.0.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",
@@ -24,7 +24,7 @@
24
24
  "report": "madrun report"
25
25
  },
26
26
  "dependencies": {
27
- "@putout/engine-parser": "^8.0.0",
27
+ "@putout/engine-parser": "^9.0.0",
28
28
  "diff-match-patch": "^1.0.4",
29
29
  "nano-memoize": "^3.0.11",
30
30
  "once": "^1.4.0",
@@ -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": "*",