putout 26.2.1 → 26.3.0

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,7 +1,17 @@
1
+ 2022.05.17, v26.3.0
2
+
3
+ feature:
4
+ - (@putout/engine-loader) add ability to pass loader
5
+ - (@putout/engine-processor) add ability to pass load
6
+ - (@putout/engine-loader) add support of load
7
+ - (putout) cli: formatter: add support of load
8
+ - (putout) worker: add ability to pass load to getProcessors
9
+
10
+
1
11
  2022.05.16, v26.2.1
2
12
 
3
13
  feature:
4
- - (putout) parse-optios: apply-module-type-rules: simplify
14
+ - (putout) parse-options: apply-module-type-rules: simplify
5
15
  - (package) @putout/processor-css v5.0.0
6
16
  - (@putout/processor-html) convert to ESM
7
17
 
@@ -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,
@@ -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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "putout",
3
- "version": "26.2.1",
3
+ "version": "26.3.0",
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",