Skip to content

Commit 35a91f8

Browse files
committed
feature: @putout/plugin-nodejs: convert-commonjs-to-esm: require: json: include
1 parent 08f23bd commit 35a91f8

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
const Pack = require('../package');
1+
import Pack from '../package';

packages/plugin-nodejs/lib/convert-commonjs-to-esm/require/index.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ const createImport = ({name, source}) => {
3636
};
3737

3838
const createFnDeclaration = template('const NAME1 = FN(NAME2)');
39-
const isPackage = ({value}) => /package(\.json)?$/.test(value);
4039

4140
export const match = () => ({
4241
'export const __a = require("__b")': ({__a}, path) => {
@@ -51,7 +50,7 @@ export const match = () => ({
5150

5251
return isProgram(path.parentPath.parentPath);
5352
},
54-
'const __a = require(__b)': ({__b}, path) => {
53+
'const __a = require(__b)': (vars, path) => {
5554
if (isExportNamedDeclaration(path.parentPath))
5655
return false;
5756

@@ -62,9 +61,6 @@ export const match = () => ({
6261

6362
const {confident, value} = __bPath.evaluate();
6463

65-
if (isPackage(__b))
66-
return false;
67-
6864
return value && confident;
6965
},
7066
'require("__a")': (vars, path) => Boolean(path.parentPath.parentPath.isProgram()),

0 commit comments

Comments
 (0)