Skip to content

Commit 5b36b75

Browse files
committed
feature: @putout/plugin-declare: migrate to ESM
1 parent d26dc8a commit 5b36b75

File tree

7 files changed

+18
-23
lines changed

7 files changed

+18
-23
lines changed
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
'use strict';
2-
3-
module.exports = {
1+
export default {
42
freshImport: 'const freshImport = ((count) => (name) => import(`${name}?count=${++count}`))(0)',
53
freshImportDefault: 'const freshImportDefault = ((count) => async (name) => (await import(`${name}?count=${++count}`)).default)(0)',
64
};

packages/plugin-declare/lib/index.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
'use strict';
1+
import object from './object.json' with {
2+
type: 'json',
3+
};
4+
import wrap from './wrap.js';
5+
import freshImport from './fresh-import.js';
6+
import fixtures from './fixtures.json' with {
7+
type: 'json',
8+
};
29

3-
const object = require('./object');
4-
const wrap = require('./wrap');
5-
const freshImport = require('./fresh-import');
6-
const fixtures = require('./fixtures');
7-
8-
module.exports.declare = () => ({
10+
export const declare = () => ({
911
...object,
1012
...wrap,
1113
...freshImport,

packages/plugin-declare/lib/wrap.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
'use strict';
2-
3-
module.exports = {
1+
export default {
42
not: 'const not = (fn) => (...a) => !fn(...a)',
53
id: 'const id = (a) => a',
64
returns: 'const returns = (a) => () => a',

packages/plugin-declare/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@putout/plugin-declare",
33
"version": "5.0.0",
4-
"type": "commonjs",
4+
"type": "module",
55
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
66
"description": "🐊Putout plugin adds ability to declare variables",
77
"homepage": "https://github.com/coderaiser/putout/tree/master/packages/plugin-declare#readme",
@@ -45,11 +45,11 @@
4545
"supertape": "^11.0.3"
4646
},
4747
"peerDependencies": {
48-
"putout": ">=38"
48+
"putout": ">=40"
4949
},
5050
"license": "MIT",
5151
"engines": {
52-
"node": ">=18"
52+
"node": ">=20"
5353
},
5454
"publishConfig": {
5555
"access": "public"

packages/plugin-declare/test/declare.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
'use strict';
1+
import {createTest} from '@putout/test';
2+
import montag from 'montag';
3+
import * as declare from '../lib/index.js';
24

3-
const {createTest} = require('@putout/test');
4-
const montag = require('montag');
5-
6-
const declare = require('..');
7-
8-
const test = createTest(__dirname, {
5+
const test = createTest(import.meta.url, {
96
plugins: [
107
['declare', declare],
118
],

0 commit comments

Comments
 (0)