Skip to content

Commit 0b705be

Browse files
committed
feature: @putout/plugin-webpack: migrate to ESM
1 parent 20c5f6b commit 0b705be

File tree

13 files changed

+39
-55
lines changed

13 files changed

+39
-55
lines changed

packages/plugin-webpack/lib/apply-externals/index.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
'use strict';
1+
import {types} from 'putout';
22

3-
const {types} = require('putout');
43
const {objectProperty, objectPattern} = types;
54
const COMPUTED = false;
65
const SHORTHAND = true;
76

8-
module.exports.report = () => `Use 'externals({context, request}, callback){...}'`;
7+
export const report = () => `Use 'externals({context, request}, callback){...}'`;
98

10-
module.exports.match = () => ({
9+
export const match = () => ({
1110
'function externals(__args) {}': ({__args}) => __args.length === 3,
1211
});
1312

14-
module.exports.replace = () => ({
13+
export const replace = () => ({
1514
'function externals(__args) {}': ({__args}, path) => {
1615
const node = objectPattern([]);
1716

packages/plugin-webpack/lib/apply-externals/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 plugin from './index.js';
23

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

packages/plugin-webpack/lib/convert-loader-to-use/index.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
'use strict';
1+
import {types, operator} from 'putout';
22

3-
const {types, operator} = require('putout');
43
const {
54
arrayExpression,
65
isStringLiteral,
@@ -10,9 +9,9 @@ const {
109

1110
const {replaceWith} = operator;
1211

13-
module.exports.report = () => `"use" should be used instead of exclamation mark in loaders`;
12+
export const report = () => `"use" should be used instead of exclamation mark in loaders`;
1413

15-
module.exports.fix = (path) => {
14+
export const fix = (path) => {
1615
const {node} = path;
1716

1817
node.key.name = 'use';
@@ -28,7 +27,7 @@ module.exports.fix = (path) => {
2827
replaceWith(valuePath, arrayExpression(elements));
2928
};
3029

31-
module.exports.traverse = ({push}) => ({
30+
export const traverse = ({push}) => ({
3231
ObjectExpression(path) {
3332
const properties = path.get('properties');
3433

packages/plugin-webpack/lib/convert-loader-to-use/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 convertLoaderToUse from './index.js';
23

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

packages/plugin-webpack/lib/convert-node-to-resolve-fallback/index.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
'use strict';
1+
import {types, operator} from 'putout';
22

3-
const {types, operator} = require('putout');
43
const {
54
identifier,
65
objectProperty,
@@ -10,9 +9,9 @@ const {
109

1110
const {replaceWith} = operator;
1211

13-
module.exports.report = () => '"resolve.fallback" should be used instead of "node"';
12+
export const report = () => '"resolve.fallback" should be used instead of "node"';
1413

15-
module.exports.fix = (path) => {
14+
export const fix = (path) => {
1615
const valuePath = path.get('value');
1716
const valueNode = valuePath.node;
1817

@@ -27,7 +26,7 @@ module.exports.fix = (path) => {
2726
]));
2827
};
2928

30-
module.exports.traverse = ({push}) => ({
29+
export const traverse = ({push}) => ({
3130
'module.exports = __object'(path) {
3231
const properties = path.get('right.properties');
3332

packages/plugin-webpack/lib/convert-node-to-resolve-fallback/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 convertNodeToResolveFallback from './index.js';
23

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

packages/plugin-webpack/lib/convert-query-loader-to-use/index.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
'use strict';
1+
import {types, operator} from 'putout';
22

3-
const {types, operator} = require('putout');
43
const {
54
objectExpression,
65
identifier,
@@ -14,9 +13,9 @@ const {
1413

1514
const {replaceWith} = operator;
1615

17-
module.exports.report = () => `"use" should be used instead of query in loaders`;
16+
export const report = () => `"use" should be used instead of query in loaders`;
1817

19-
module.exports.fix = (path) => {
18+
export const fix = (path) => {
2019
const {node} = path;
2120

2221
node.key.name = 'use';
@@ -28,7 +27,7 @@ module.exports.fix = (path) => {
2827
replaceWith(valuePath, arrayExpression([object]));
2928
};
3029

31-
module.exports.traverse = ({push}) => ({
30+
export const traverse = ({push}) => ({
3231
ObjectExpression(path) {
3332
const properties = path.get('properties');
3433

packages/plugin-webpack/lib/convert-query-loader-to-use/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 convertQueryLoaderToUse from './index.js';
23

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

0 commit comments

Comments
 (0)