putout 26.2.0 → 26.3.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/ChangeLog CHANGED
@@ -1,3 +1,27 @@
1
+ 2022.05.17, v26.3.1
2
+
3
+ feature:
4
+ - (putout) add ability to override import of processors for yarn pnp
5
+
6
+
7
+ 2022.05.17, v26.3.0
8
+
9
+ feature:
10
+ - (@putout/engine-loader) add ability to pass loader
11
+ - (@putout/engine-processor) add ability to pass load
12
+ - (@putout/engine-loader) add support of load
13
+ - (putout) cli: formatter: add support of load
14
+ - (putout) worker: add ability to pass load to getProcessors
15
+
16
+
17
+ 2022.05.16, v26.2.1
18
+
19
+ feature:
20
+ - (putout) parse-options: apply-module-type-rules: simplify
21
+ - (package) @putout/processor-css v5.0.0
22
+ - (@putout/processor-html) convert to ESM
23
+
24
+
1
25
  2022.05.15, v26.2.0
2
26
 
3
27
  feature:
@@ -2,6 +2,7 @@
2
2
 
3
3
  const tryToCatch = require('try-to-catch');
4
4
  const {createAsyncLoader} = require('@putout/engine-loader');
5
+ const {simpleImport} = require('./simple-import');
5
6
 
6
7
  const {
7
8
  NO_FORMATTER,
@@ -15,7 +16,7 @@ module.exports.getFormatter = async (formatterOptional, exit) => {
15
16
  const [formatterName, formatterOptions] = maybeArray(formatterOptional);
16
17
  const loadFormatter = createAsyncLoader('formatter');
17
18
 
18
- const [error, formatter] = await tryToCatch(loadFormatter, formatterName, exit);
19
+ const [error, formatter] = await tryToCatch(loadFormatter, formatterName, simpleImport);
19
20
 
20
21
  if (formatter)
21
22
  return [formatter, formatterOptions];
package/lib/cli/index.js CHANGED
@@ -11,10 +11,7 @@ const fullstore = require('fullstore');
11
11
 
12
12
  const keyPress = require('@putout/cli-keypress');
13
13
  const {version} = require('../../package.json');
14
- const {
15
- simpleImport,
16
- simpleImportDefault,
17
- } = require('./simple-import');
14
+ const {simpleImport} = require('./simple-import');
18
15
  const {run} = require('./runner/runner.js');
19
16
 
20
17
  const {
@@ -144,7 +141,7 @@ module.exports = async ({argv, halt, log, write, logError, readFile, writeFile})
144
141
  plugins,
145
142
  } = args;
146
143
 
147
- const {red} = await simpleImportDefault('chalk');
144
+ const {red} = await simpleImport('chalk');
148
145
  const exit = getExit({
149
146
  red,
150
147
  raw,
@@ -215,7 +212,7 @@ module.exports = async ({argv, halt, log, write, logError, readFile, writeFile})
215
212
  } = config;
216
213
 
217
214
  const [currentFormat, formatterOptions] = await getFormatter(format || formatter, exit);
218
- const [error, processorRunners] = await tryToCatch(getProcessorRunners, processors);
215
+ const [error, processorRunners] = await tryToCatch(getProcessorRunners, processors, simpleImport);
219
216
 
220
217
  if (error)
221
218
  return exit(CANNOT_LOAD_PROCESSOR, error);
@@ -12,6 +12,7 @@ const {runProcessors} = require('@putout/engine-processor');
12
12
 
13
13
  const parseError = require('../parse-error.js');
14
14
  const getOptions = require('../get-options.js');
15
+ const {simpleImport} = require('../simple-import');
15
16
  const {
16
17
  INVALID_CONFIG,
17
18
  NO_PROCESSORS,
@@ -92,6 +93,7 @@ module.exports = async ({readFile, report, writeFile, exit, raw, write, log, cur
92
93
  options,
93
94
  rawSource,
94
95
  processorRunners,
96
+ load: simpleImport,
95
97
  });
96
98
 
97
99
  if (error) {
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
- // How in other way to mock import using mock require in CommonJS?
4
- module.exports.simpleImportDefault = async (url) => (await import(url)).default;
5
- module.exports.simpleImport = async (url) => await import(url);
3
+ module.exports.simpleImport = async (url) => {
4
+ const result = await import(url);
5
+ return result.default || result;
6
+ };
6
7
 
@@ -1,25 +1,37 @@
1
1
  'use strict';
2
2
 
3
3
  const {assign} = Object;
4
- const getRuleByType = (a) => a === 'module' ? 'convert-commonjs-to-esm' : 'convert-esm-to-commonjs';
4
+ const merge = require('../merge');
5
5
 
6
6
  module.exports = ({type}, options) => {
7
- const rule = getRuleByType(type);
8
- const js = '*.js';
9
-
10
- assign(options, {
7
+ const rules = type === 'module' ? esm() : commonjs();
8
+ assign(options, merge(options, rules));
9
+ };
10
+
11
+ function commonjs() {
12
+ return {
11
13
  match: {
12
- ...options.match,
13
- [js]: {
14
- ...options.match?.[js],
15
- [rule]: 'on',
14
+ '*.js': {
15
+ 'convert-esm-to-commonjs': 'on',
16
16
  },
17
17
  '.eslintrc.json': {
18
- ...options.match?.['.eslintrc.json'],
19
18
  'eslint': 'on',
20
- 'eslint/convert-require-to-import': type === 'module' ? 'on' : 'off',
19
+ 'eslint/convert-require-to-import': 'off',
21
20
  },
22
21
  },
23
- });
24
- };
22
+ };
23
+ }
25
24
 
25
+ function esm() {
26
+ return {
27
+ match: {
28
+ '*.js': {
29
+ 'convert-commonjs-to-esm': 'on',
30
+ },
31
+ '.eslintrc.json': {
32
+ 'eslint': 'on',
33
+ 'eslint/convert-require-to-import': 'on',
34
+ },
35
+ },
36
+ };
37
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "putout",
3
- "version": "26.2.0",
3
+ "version": "26.3.1",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊 Pluggable and configurable code transformer with built-in eslint and babel plugins support of js, jsx typescript, flow files, markdown, yaml and json",