@putout/engine-loader 17.0.0 → 17.0.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/load/async-loader.js +3 -1
- package/lib/load/load.js +4 -5
- package/lib/plugins/load-plugins.js +3 -1
- package/package.json +2 -1
- package/rules/README.md +3 -0
- package/rules/apply-import-module/fixture/apply-import-module-fix.js +6 -0
- package/rules/apply-import-module/fixture/apply-import-module.js +3 -0
- package/rules/apply-import-module/fixture/as-fix.js +6 -0
- package/rules/apply-import-module/fixture/as.js +5 -0
- package/rules/apply-import-module/fixture/stub.js +4 -0
- package/rules/apply-import-module/fixture/test.js +4 -0
- package/rules/apply-import-module/index.js +32 -0
package/lib/load/async-loader.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import process from 'node:process';
|
|
2
2
|
import {join} from 'node:path';
|
|
3
|
-
import
|
|
3
|
+
import module from 'node:module';
|
|
4
4
|
import tryToCatch from 'try-to-catch';
|
|
5
5
|
import {simpleImport as _simpleImport} from './simple-import.js';
|
|
6
6
|
|
|
7
|
+
const {createRequire} = module;
|
|
8
|
+
|
|
7
9
|
const require = createRequire(import.meta.url);
|
|
8
10
|
const {assign} = Object;
|
|
9
11
|
const stub = () => () => {};
|
package/lib/load/load.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import process from 'node:process';
|
|
2
|
-
import
|
|
3
|
-
createRequire as _createRequire,
|
|
4
|
-
createRequire,
|
|
5
|
-
} from 'node:module';
|
|
2
|
+
import module from 'node:module';
|
|
6
3
|
import {join} from 'node:path';
|
|
7
4
|
import tryCatch from 'try-catch';
|
|
8
5
|
|
|
9
|
-
const
|
|
6
|
+
const {createRequire: _createRequire} = module;
|
|
7
|
+
|
|
8
|
+
const require = _createRequire(import.meta.url);
|
|
10
9
|
const bigFirst = (a) => `${a[0].toUpperCase()}${a.slice(1)}`;
|
|
11
10
|
|
|
12
11
|
const load = (type) => (overrides) => {
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import module from 'node:module';
|
|
2
2
|
import validatePlugin from './validate-plugin.js';
|
|
3
3
|
import {prepareRules} from './prepare-rules.js';
|
|
4
4
|
import {isEnabled} from '../rules/index.js';
|
|
5
5
|
import {filterEnabledPlugins} from './filter-enabled-plugins.js';
|
|
6
6
|
import {check, checkRule} from '../check/index.js';
|
|
7
7
|
|
|
8
|
+
const {createRequire} = module;
|
|
9
|
+
|
|
8
10
|
const require = createRequire(import.meta.url);
|
|
9
11
|
|
|
10
12
|
const {isArray} = Array;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/engine-loader",
|
|
3
|
-
"version": "17.0.
|
|
3
|
+
"version": "17.0.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "load plugins and prepare them to run",
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"@putout/plugin-remove-debugger": "*",
|
|
45
45
|
"@putout/processor-javascript": "*",
|
|
46
46
|
"@putout/processor-markdown": "*",
|
|
47
|
+
"@putout/test": "^14.2.0",
|
|
47
48
|
"c8": "^10.0.0",
|
|
48
49
|
"eslint": "^10.0.0-alpha.0",
|
|
49
50
|
"eslint-plugin-n": "^17.0.0",
|
package/rules/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {operator} from 'putout';
|
|
2
|
+
|
|
3
|
+
const {compare} = operator;
|
|
4
|
+
|
|
5
|
+
export const report = () => `Use 'import {createRequire}' -> 'import module' for rollup'`;
|
|
6
|
+
|
|
7
|
+
export const match = () => ({
|
|
8
|
+
'import {createRequire} from "node:module"': isTest,
|
|
9
|
+
'const require = createRequire(import.meta.url)': isTest,
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export const replace = () => ({
|
|
13
|
+
'import {createRequire} from "node:module"': `{
|
|
14
|
+
import module from "node:module";
|
|
15
|
+
const {createRequire} = module;
|
|
16
|
+
}`,
|
|
17
|
+
'import {createRequire as __a} from "node:module"': `{
|
|
18
|
+
import module from "node:module";
|
|
19
|
+
const {createRequire: __a} = module;
|
|
20
|
+
}`,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
function isTest(vars, path) {
|
|
24
|
+
const {body} = path.parentPath.node;
|
|
25
|
+
|
|
26
|
+
for (const current of body) {
|
|
27
|
+
if (compare(current, 'import __imports from "supertape"'))
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return true;
|
|
32
|
+
}
|