Skip to content

Commit 0febc6c

Browse files
committed
feature: @putout/plugin-postcss: convert tot ESM
1 parent 5dcf23a commit 0febc6c

File tree

5 files changed

+18
-26
lines changed

5 files changed

+18
-26
lines changed
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
'use strict';
1+
import * as replacePluginWithCreator from './replace-plugin-with-creator/index.js';
22

3-
const getRule = (a) => ({
4-
[a]: require(`./${a}`),
5-
});
6-
7-
module.exports.rules = getRule('replace-plugin-with-creator');
3+
export const rules = {
4+
'replace-plugin-with-creator': replacePluginWithCreator,
5+
};

packages/plugin-postcss/lib/replace-plugin-with-creator/index.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
'use strict';
2-
3-
const {
1+
import {
42
operator,
53
template,
64
types,
7-
} = require('putout');
5+
} from 'putout';
86

97
const {
108
objectExpression,
@@ -17,9 +15,9 @@ const {traverse, insertAfter} = operator;
1715

1816
const booleanExport = template.ast('module.exports.postcss = true');
1917

20-
module.exports.report = () => 'creator should be used instead of plugin';
18+
export const report = () => 'creator should be used instead of plugin';
2119

22-
module.exports.replace = () => ({
20+
export const replace = () => ({
2321
'module.exports = __(__a, __b)': ({__a, __b}, path) => {
2422
path.node.right = __b;
2523

packages/plugin-postcss/lib/replace-plugin-with-creator/index.spec.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
'use strict';
1+
import {createTest} from '@putout/test';
2+
import * as replacePluginWithCreator from './index.js';
23

3-
const {createTest} = require('@putout/test');
4-
const replacePluginWithCreator = require('.');
5-
6-
const test = createTest(__dirname, {
4+
const test = createTest(import.meta.url, {
75
plugins: [
86
['postcss/replace-plugin-with-creator', replacePluginWithCreator],
97
],

packages/plugin-postcss/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"name": "@putout/plugin-postcss",
33
"version": "1.0.0",
4-
"type": "commonjs",
4+
"type": "module",
55
"author": "coderaiser <[email protected]> (https://github.com/coderaiser)",
6-
"description": "🐊Putout plugin helps with migration to latest postcss",
6+
"description": "🐊Putout plugin helps with migration to latest PostCSS",
77
"homepage": "https://github.com/coderaiser/putout/tree/master/packages/plugin-postcss#readme",
88
"main": "lib/index.js",
99
"release": false,
@@ -41,11 +41,11 @@
4141
"nodemon": "^3.0.1"
4242
},
4343
"peerDependencies": {
44-
"putout": ">=10"
44+
"putout": ">=39"
4545
},
4646
"license": "MIT",
4747
"engines": {
48-
"node": ">=12"
48+
"node": ">=20"
4949
},
5050
"publishConfig": {
5151
"access": "public"

packages/plugin-postcss/test/postcss.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
'use strict';
1+
import {createTest} from '@putout/test';
2+
import * as postcss from '../lib/index.js';
23

3-
const {createTest} = require('@putout/test');
4-
const postcss = require('..');
5-
6-
const test = createTest(__dirname, {
4+
const test = createTest(import.meta.url, {
75
plugins: [
86
['postcss', postcss],
97
],

0 commit comments

Comments
 (0)