From 60761648ecaabf9dd5348185fbdb1b0f3f1c601e Mon Sep 17 00:00:00 2001 From: Ivan Demidov Date: Thu, 24 Oct 2019 16:59:56 +0300 Subject: [PATCH 01/13] ci(*): drop support old node --- .travis.yml | 3 +-- package.json | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index d84955b..72d6657 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,8 +3,7 @@ language: node_js node_js: - stable - lts/* - - 6 - - 4 + - 8 after_success: - cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js" diff --git a/package.json b/package.json index 36315e9..8749852 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "version": "1.0.2", "main": "lib/index.js", "engines": { - "node": ">= 4" + "node": ">= 8" }, "files": [ "lib" From 39028e2861d432dcb174bf4301d8e27a3a0216b4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Jul 2020 21:39:52 +0000 Subject: [PATCH 02/13] build(deps-dev): bump standard-version from 7.1.0 to 8.0.1 Bumps [standard-version](https://github.com/conventional-changelog/standard-version) from 7.1.0 to 8.0.1. - [Release notes](https://github.com/conventional-changelog/standard-version/releases) - [Changelog](https://github.com/conventional-changelog/standard-version/blob/master/CHANGELOG.md) - [Commits](https://github.com/conventional-changelog/standard-version/compare/v7.1.0...v8.0.1) Signed-off-by: dependabot[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8749852..4efdc47 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "memory-fs": "^0.5.0", "posthtml-sugarml": "1.0.0-alpha3", "standard": "^14.3.1", - "standard-version": "^7.0.0", + "standard-version": "^8.0.1", "webpack": "^4.41.2" }, "keywords": [ From a8bc4b6c075ef7b9ed27543084d0d489be955cfd Mon Sep 17 00:00:00 2001 From: Ivan Demidov Date: Fri, 21 Aug 2020 10:58:52 +0300 Subject: [PATCH 03/13] test: fix snapshot typo --- test/__snapshots__/Errors.test.js.snap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/__snapshots__/Errors.test.js.snap b/test/__snapshots__/Errors.test.js.snap index 24ed990..c0e5d47 100644 --- a/test/__snapshots__/Errors.test.js.snap +++ b/test/__snapshots__/Errors.test.js.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Errors Validation Error 1`] = ` -"Invalid options object. PostHTML Loader has been initialised using an options object that does not match the API schema. +"Invalid options object. PostHTML Loader has been initialized using an options object that does not match the API schema. - options.plugins should be one of these: [any, ...] | object { … } | function Details: From 1bb856839c098f059d82b6b395c9bb61c249f14c Mon Sep 17 00:00:00 2001 From: Ivan Demidov Date: Fri, 21 Aug 2020 11:01:48 +0300 Subject: [PATCH 04/13] docs: me to maintainer --- README.md | 9 --------- 1 file changed, 9 deletions(-) diff --git a/README.md b/README.md index b0378aa..e193a88 100644 --- a/README.md +++ b/README.md @@ -202,15 +202,6 @@ Plugins are specified under the `plugins` key in the loader options
Michael Ciniawsky - - - - -

Contributors

- - - -

From 6872b154ed7913b2eb83620b41c48cf1a72a99c8 Mon Sep 17 00:00:00 2001 From: Ivan Demidov Date: Fri, 21 Aug 2020 11:55:32 +0300 Subject: [PATCH 05/13] perf: options render --- README.md | 29 ++++++++++++ lib/index.js | 7 ++- .../options/__snapshots__/render.test.js.snap | 5 +++ test/options/render.test.js | 45 +++++++++++++++++++ 4 files changed, 82 insertions(+), 4 deletions(-) create mode 100644 test/options/__snapshots__/render.test.js.snap create mode 100644 test/options/render.test.js diff --git a/README.md b/README.md index e193a88..3baa00b 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,7 @@ module: { |:--:|:--:|:-----:|:----------| |**[`config`](#config)**|`{Object}`|`undefined`|PostHTML Config| |**[`parser`](#parser)**|`{String/Function}`|`undefined`|PostHTML Parser| +|**[`render`](#parser)**|`{String/Function}`|`undefined`|PostHTML Render| |**[`plugins`](#plugins)**|`{Array/Function}`|`[]`|PostHTML Plugins| ### `Config` @@ -157,6 +158,34 @@ If you want to use a custom parser e.g [SugarML](https://github.com/posthtml/sug } ``` +### `Render` + +If you want to use a custom render, you can pass it in under the `render` key in the loader options + +#### `{String}` + +**webpack.config.js** +```js +{ + loader: 'posthtml-loader', + options: { + render: 'posthtml-you-render' + } +} +``` + +#### `{Function}` + +**webpack.config.js** +```js +{ + loader: 'posthtml-loader', + options: { + parser: require('posthtml-you-render')() + } +} +``` + ### `Plugins` Plugins are specified under the `plugins` key in the loader options diff --git a/lib/index.js b/lib/index.js index 735918b..920ddf9 100644 --- a/lib/index.js +++ b/lib/index.js @@ -106,10 +106,9 @@ module.exports = function loader (html, map, meta) { options.parser = require(options.parser)() } - // TODO(michael-ciniawsky) enable if when custom renderer available - // if (typeof options.render === 'string') { - // options.render = require(options.render)() - // } + if (typeof options.render === 'string') { + options.render = require(options.render)() + } return posthtml(plugins) .process(html, options) diff --git a/test/options/__snapshots__/render.test.js.snap b/test/options/__snapshots__/render.test.js.snap new file mode 100644 index 0000000..ee30f5f --- /dev/null +++ b/test/options/__snapshots__/render.test.js.snap @@ -0,0 +1,5 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Options render {Object} 1`] = `"throw new Error(\\"Module parse failed: Unexpected token (1:4)\\\\nYou may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders\\\\n> div Hello\\\\n| \\");"`; + +exports[`Options render {String} 1`] = `"throw new Error(\\"Module parse failed: Unexpected token (1:4)\\\\nYou may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders\\\\n> div Hello\\\\n| \\");"`; diff --git a/test/options/render.test.js b/test/options/render.test.js new file mode 100644 index 0000000..a5cc3de --- /dev/null +++ b/test/options/render.test.js @@ -0,0 +1,45 @@ +'use strict' + +const webpack = require('../helpers/compiler') + +describe('Options', () => { + describe('render', () => { + test('{String}', () => { + const config = { + loader: { + test: /\.html$/, + options: { + render: 'posthtml-render' + } + } + } + + return webpack('options/parser/fixture.js', config) + .then((stats) => { + const module = stats.toJson().modules[1] + + expect(module.source).toMatchSnapshot() + }) + .catch((err) => err) + }) + + test('{Object}', () => { + const config = { + loader: { + test: /\.html$/, + options: { + parser: require('posthtml-render')() + } + } + } + + return webpack('options/parser/fixture.js', config) + .then((stats) => { + const module = stats.toJson().modules[1] + + expect(module.source).toMatchSnapshot() + }) + .catch((err) => err) + }) + }) +}) From 83acecf518bbe26e97a9c40a716f98bbb0b39d4c Mon Sep 17 00:00:00 2001 From: Ivan Demidov Date: Fri, 21 Aug 2020 14:25:13 +0300 Subject: [PATCH 06/13] test: repair snapshot test --- test/__snapshots__/loader.test.js.snap | 6 ++++++ test/fixtures/options/render/fixture.html | 1 + test/fixtures/options/render/fixture.js | 1 + test/helpers/compiler.js | 1 + test/loader.test.js | 2 +- test/options/__snapshots__/config.test.js.snap | 11 +++++++++++ test/options/__snapshots__/parser.test.js.snap | 5 +++++ test/options/__snapshots__/plugins.test.js.snap | 16 ++++++++++++++++ test/options/__snapshots__/render.test.js.snap | 4 ++-- test/options/config.test.js | 4 ++-- test/options/plugins.test.js | 8 ++++---- test/options/render.test.js | 12 ++++++------ 12 files changed, 56 insertions(+), 15 deletions(-) create mode 100644 test/__snapshots__/loader.test.js.snap create mode 100644 test/fixtures/options/render/fixture.html create mode 100644 test/fixtures/options/render/fixture.js create mode 100644 test/options/__snapshots__/config.test.js.snap create mode 100644 test/options/__snapshots__/parser.test.js.snap create mode 100644 test/options/__snapshots__/plugins.test.js.snap diff --git a/test/__snapshots__/loader.test.js.snap b/test/__snapshots__/loader.test.js.snap new file mode 100644 index 0000000..1421543 --- /dev/null +++ b/test/__snapshots__/loader.test.js.snap @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Loader Defaults 1`] = ` +"export default \`
Hello
+\`" +`; diff --git a/test/fixtures/options/render/fixture.html b/test/fixtures/options/render/fixture.html new file mode 100644 index 0000000..5782fa3 --- /dev/null +++ b/test/fixtures/options/render/fixture.html @@ -0,0 +1 @@ +Hello \ No newline at end of file diff --git a/test/fixtures/options/render/fixture.js b/test/fixtures/options/render/fixture.js new file mode 100644 index 0000000..310cfd2 --- /dev/null +++ b/test/fixtures/options/render/fixture.js @@ -0,0 +1 @@ +import html from './fixture.html' // eslint-disable-line diff --git a/test/helpers/compiler.js b/test/helpers/compiler.js index 93cce61..6ee2db7 100644 --- a/test/helpers/compiler.js +++ b/test/helpers/compiler.js @@ -46,6 +46,7 @@ const output = (config) => { module.exports = function (fixture, config, options) { config = { + mode: 'development', devtool: config.devtool || 'sourcemap', context: path.resolve(__dirname, '..', 'fixtures'), entry: `./${fixture}`, diff --git a/test/loader.test.js b/test/loader.test.js index ff14a9f..1603e1e 100644 --- a/test/loader.test.js +++ b/test/loader.test.js @@ -13,7 +13,7 @@ describe('Loader', () => { return webpack('fixture.js', config) .then((stats) => { - const module = stats.toJson().modules[1] + const [module] = stats.toJson().modules expect(module.source).toMatchSnapshot() }) diff --git a/test/options/__snapshots__/config.test.js.snap b/test/options/__snapshots__/config.test.js.snap new file mode 100644 index 0000000..b721f8a --- /dev/null +++ b/test/options/__snapshots__/config.test.js.snap @@ -0,0 +1,11 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Options config ctx - {Object} 1`] = ` +"export default \`
Hello
+\`" +`; + +exports[`Options config path - {String} 1`] = ` +"export default \`
Hello
+\`" +`; diff --git a/test/options/__snapshots__/parser.test.js.snap b/test/options/__snapshots__/parser.test.js.snap new file mode 100644 index 0000000..b106d4d --- /dev/null +++ b/test/options/__snapshots__/parser.test.js.snap @@ -0,0 +1,5 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Options parser {Object} 1`] = `"export default \`
Hello
\`"`; + +exports[`Options parser {String} 1`] = `"export default \`
Hello
\`"`; diff --git a/test/options/__snapshots__/plugins.test.js.snap b/test/options/__snapshots__/plugins.test.js.snap new file mode 100644 index 0000000..3ad6b08 --- /dev/null +++ b/test/options/__snapshots__/plugins.test.js.snap @@ -0,0 +1,16 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Options plugins {Array} 1`] = ` +"export default \`
Hello
+\`" +`; + +exports[`Options plugins {Function} - {Array} 1`] = ` +"export default \`
Hello
+\`" +`; + +exports[`Options plugins {Function} - {Object} 1`] = ` +"export default \`
Hello
+\`" +`; diff --git a/test/options/__snapshots__/render.test.js.snap b/test/options/__snapshots__/render.test.js.snap index ee30f5f..a943fdf 100644 --- a/test/options/__snapshots__/render.test.js.snap +++ b/test/options/__snapshots__/render.test.js.snap @@ -1,5 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Options render {Object} 1`] = `"throw new Error(\\"Module parse failed: Unexpected token (1:4)\\\\nYou may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders\\\\n> div Hello\\\\n| \\");"`; +exports[`Options render {Object} 1`] = `"export default \`Hello\`"`; -exports[`Options render {String} 1`] = `"throw new Error(\\"Module parse failed: Unexpected token (1:4)\\\\nYou may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders\\\\n> div Hello\\\\n| \\");"`; +exports[`Options render {String} 1`] = `"export default \`Hello\`"`; diff --git a/test/options/config.test.js b/test/options/config.test.js index 5aecd0d..906d5df 100644 --- a/test/options/config.test.js +++ b/test/options/config.test.js @@ -18,7 +18,7 @@ describe('Options', () => { return webpack('fixture.js', config) .then((stats) => { - const module = stats.toJson().modules[1] + const [module] = stats.toJson().modules expect(module.source).toMatchSnapshot() }) @@ -40,7 +40,7 @@ describe('Options', () => { return webpack('fixture.js', config) .then((stats) => { - const module = stats.toJson().modules[1] + const [module] = stats.toJson().modules expect(module.source).toMatchSnapshot() }) diff --git a/test/options/plugins.test.js b/test/options/plugins.test.js index 36023e7..44c6866 100644 --- a/test/options/plugins.test.js +++ b/test/options/plugins.test.js @@ -19,7 +19,7 @@ describe('Options', () => { return webpack('fixture.js', config) .then((stats) => { - const module = stats.toJson().modules[1] + const [module] = stats.toJson().modules expect(module.source).toMatchSnapshot() }) @@ -43,14 +43,14 @@ describe('Options', () => { return webpack('fixture.js', config) .then((stats) => { - const module = stats.toJson().modules[1] + const [module] = stats.toJson().modules expect(module.source).toMatchSnapshot() }) .catch((err) => err) }) - test('{Function} - {Object}', () => { + test.only('{Function} - {Object}', () => { const config = { loader: { test: /\.html$/, @@ -65,7 +65,7 @@ describe('Options', () => { return webpack('fixture.js', config) .then((stats) => { - const module = stats.toJson().modules[1] + const [module] = stats.toJson().modules expect(module.source).toMatchSnapshot() }) diff --git a/test/options/render.test.js b/test/options/render.test.js index a5cc3de..2c23811 100644 --- a/test/options/render.test.js +++ b/test/options/render.test.js @@ -14,28 +14,28 @@ describe('Options', () => { } } - return webpack('options/parser/fixture.js', config) + return webpack('options/render/fixture.js', config) .then((stats) => { - const module = stats.toJson().modules[1] + const [module] = stats.toJson().modules expect(module.source).toMatchSnapshot() }) .catch((err) => err) }) - test('{Object}', () => { + test.only('{Object}', () => { const config = { loader: { test: /\.html$/, options: { - parser: require('posthtml-render')() + parser: require('posthtml-render') } } } - return webpack('options/parser/fixture.js', config) + return webpack('options/render/fixture.js', config) .then((stats) => { - const module = stats.toJson().modules[1] + const [module] = stats.toJson().modules expect(module.source).toMatchSnapshot() }) From 8024ec7d98e7d1106857e32dea8a330918a30f18 Mon Sep 17 00:00:00 2001 From: Ivan Demidov Date: Fri, 21 Aug 2020 14:56:09 +0300 Subject: [PATCH 07/13] test: remove only --- test/options/plugins.test.js | 2 +- test/options/render.test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/options/plugins.test.js b/test/options/plugins.test.js index 44c6866..7784bc6 100644 --- a/test/options/plugins.test.js +++ b/test/options/plugins.test.js @@ -50,7 +50,7 @@ describe('Options', () => { .catch((err) => err) }) - test.only('{Function} - {Object}', () => { + test('{Function} - {Object}', () => { const config = { loader: { test: /\.html$/, diff --git a/test/options/render.test.js b/test/options/render.test.js index 2c23811..68091fd 100644 --- a/test/options/render.test.js +++ b/test/options/render.test.js @@ -23,7 +23,7 @@ describe('Options', () => { .catch((err) => err) }) - test.only('{Object}', () => { + test('{Object}', () => { const config = { loader: { test: /\.html$/, From fe9e33278692f2f0edcbcd576db708832f018ca0 Mon Sep 17 00:00:00 2001 From: Ivan Demidov Date: Fri, 21 Aug 2020 14:56:49 +0300 Subject: [PATCH 08/13] test: for posthtml options, issue #124 --- test/fixtures/options/directives/fixture.html | 1 + test/fixtures/options/directives/fixture.js | 1 + .../__snapshots__/directives.test.js.snap | 3 ++ test/options/directives.test.js | 30 +++++++++++++++++++ 4 files changed, 35 insertions(+) create mode 100644 test/fixtures/options/directives/fixture.html create mode 100644 test/fixtures/options/directives/fixture.js create mode 100644 test/options/__snapshots__/directives.test.js.snap create mode 100644 test/options/directives.test.js diff --git a/test/fixtures/options/directives/fixture.html b/test/fixtures/options/directives/fixture.html new file mode 100644 index 0000000..05402e3 --- /dev/null +++ b/test/fixtures/options/directives/fixture.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/fixtures/options/directives/fixture.js b/test/fixtures/options/directives/fixture.js new file mode 100644 index 0000000..310cfd2 --- /dev/null +++ b/test/fixtures/options/directives/fixture.js @@ -0,0 +1 @@ +import html from './fixture.html' // eslint-disable-line diff --git a/test/options/__snapshots__/directives.test.js.snap b/test/options/__snapshots__/directives.test.js.snap new file mode 100644 index 0000000..28578a0 --- /dev/null +++ b/test/options/__snapshots__/directives.test.js.snap @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Options directives {Array} 1`] = `"export default \`\`"`; diff --git a/test/options/directives.test.js b/test/options/directives.test.js new file mode 100644 index 0000000..971914f --- /dev/null +++ b/test/options/directives.test.js @@ -0,0 +1,30 @@ +'use strict' + +const webpack = require('../helpers/compiler') + +describe('Options', () => { + describe('directives', () => { + test('{Array}', () => { + const config = { + loader: { + test: /\.html$/, + options: { + directives: [{ + name: '?php', + start: '<', + end: '>', + }] + } + } + } + + return webpack('options/directives/fixture.js', config) + .then((stats) => { + const [module] = stats.toJson().modules + + expect(module.source).toMatchSnapshot() + }) + .catch((err) => err) + }) + }) +}) From fd79d32b99dec231b389508d41ba6f2598fdfcb6 Mon Sep 17 00:00:00 2001 From: Ivan Demidov Date: Fri, 21 Aug 2020 15:10:03 +0300 Subject: [PATCH 09/13] fix: support all posthtml options, close #124 --- README.md | 54 +++++++++++++++++++++++++++++++++++++++++++++++- lib/options.js | 23 +++++++-------------- lib/options.json | 30 +++++++++++++++++++++++++++ 3 files changed, 91 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 3baa00b..a5d7005 100644 --- a/README.md +++ b/README.md @@ -57,8 +57,11 @@ module: { |:--:|:--:|:-----:|:----------| |**[`config`](#config)**|`{Object}`|`undefined`|PostHTML Config| |**[`parser`](#parser)**|`{String/Function}`|`undefined`|PostHTML Parser| -|**[`render`](#parser)**|`{String/Function}`|`undefined`|PostHTML Render| +|**[`skipParse`](#skipParse)**|`{Boolean}`|`false`|PostHTML Options SkipParse| +|**[`render`](#render)**|`{String/Function}`|`undefined`|PostHTML Render| |**[`plugins`](#plugins)**|`{Array/Function}`|`[]`|PostHTML Plugins| +|**[`sync`](#sync)**|`{boolean}`|`false`|PostHTML Options Sync| +|**[`directives`](#directives)**|`{Array}`|`[]`|PostHTML Options custom [Directives](https://github.com/posthtml/posthtml-parser#directives)| ### `Config` @@ -67,6 +70,7 @@ module: { |**[`path`](#path)**|`{String}`|`loader.resourcePath`|PostHTML Config Path| |**[`ctx`](#context)**|`{Object}`|`{}`|PostHTML Config Context| + If you want to use are shareable config file instead of inline options in your `webpack.config.js` create a `posthtml.config.js` file and place it somewhere down the file tree in your project. The nearest config relative to `dirname(file)` currently processed by the loader applies. This enables **Config Cascading**. Despite some edge cases the config file will be loaded automatically and **no** additional setup is required. If you don't intend to use Config Cascading, it's recommended to place `posthtml.config.js` in the **root** `./` of your project ``` @@ -158,6 +162,22 @@ If you want to use a custom parser e.g [SugarML](https://github.com/posthtml/sug } ``` +### `skipParse` + +If you want to use disable parsing, you can pass it in under the `skipParse` key in the loader options + +#### `{Boolean}` + +**webpack.config.js** +```js +{ + loader: 'posthtml-loader', + options: { + skipParse: false + } +} +``` + ### `Render` If you want to use a custom render, you can pass it in under the `render` key in the loader options @@ -220,6 +240,38 @@ Plugins are specified under the `plugins` key in the loader options } ``` +### `Sync` + +Enables sync mode, plugins will run synchronously, throws an error when used with async plugins + +#### `{Boolean}` + +**webpack.config.js** +```js +{ + loader: 'posthtml-loader', + options: { + sync: true + } +} +``` + +### `Directives` + +If you want to use a custom directives, you can pass it in under the `directives` key in the loader options + +#### `{Array}` + +**webpack.config.js** +```js +{ + loader: 'posthtml-loader', + options: { + directives: [{name: '?php', start: '<', end: '>'}] + } +} +``` +

Maintainer

diff --git a/lib/options.js b/lib/options.js index addbf22..fd3e9cc 100644 --- a/lib/options.js +++ b/lib/options.js @@ -1,22 +1,15 @@ 'use strict' module.exports = function parseOptions (params) { - if (typeof params.plugins === 'function') { - params.plugins = params.plugins.call(this, this) - } - - let plugins - - if (typeof params.plugins === 'undefined') plugins = [] - else if (Array.isArray(params.plugins)) plugins = params.plugins - else plugins = [params.plugins] + let {plugins, ...options} = params; - const options = {} - - if (typeof params !== 'undefined') { - options.parser = params.parser - // options.render = params.render + if (typeof plugins === 'function') { + plugins = plugins.call(this, this) } - return Promise.resolve({ options: options, plugins: plugins }) + if (typeof plugins === 'undefined') plugins = [] + else if (Array.isArray(plugins)) plugins = plugins + else plugins = [plugins] + + return Promise.resolve({ options, plugins }) } diff --git a/lib/options.json b/lib/options.json index 314f6dd..7cdfb25 100644 --- a/lib/options.json +++ b/lib/options.json @@ -1,6 +1,29 @@ { "type": "object", "properties": { + "sync": { + "type": "boolean" + }, + "directives": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "start": { + "type": "string" + }, + "end": { + "type": "string" + } + } + } + }, + "skipParse": { + "type": "boolean" + }, "ident": { "type": "string" }, @@ -23,6 +46,13 @@ { "instanceof": "Function" } ] }, + "render": { + "oneOf": [ + { "type": "string" }, + { "type": "object" }, + { "instanceof": "Function" } + ] + }, "plugins": { "oneOf": [ { "type": "array" }, From 714da6e7cc8e6a229a44fec395ee1c66d9102831 Mon Sep 17 00:00:00 2001 From: Ivan Demidov Date: Fri, 21 Aug 2020 15:15:37 +0300 Subject: [PATCH 10/13] build: update dep dev --- package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 4efdc47..b5d2169 100644 --- a/package.json +++ b/package.json @@ -18,20 +18,20 @@ "release": "standard-version" }, "dependencies": { - "loader-utils": "^1.1.0", - "posthtml": "^0.12.0", + "loader-utils": "^2.0.0", + "posthtml": "^0.13.2", "posthtml-load-config": "^1.0.0", "schema-utils": "^2.5.0" }, "devDependencies": { "coveralls": "^3.0.7", "del": "^5.1.0", - "jest": "^24.9.0", - "jsdoc-to-markdown": "^5.0.2", + "jest": "^26.4.1", + "jsdoc-to-markdown": "^6.0.1", "memory-fs": "^0.5.0", "posthtml-sugarml": "1.0.0-alpha3", "standard": "^14.3.1", - "standard-version": "^8.0.1", + "standard-version": "^9.0.0", "webpack": "^4.41.2" }, "keywords": [ From 9d88c55f1880e80b73d59ab880ef5e9e6b4c87f7 Mon Sep 17 00:00:00 2001 From: Ivan Demidov Date: Fri, 21 Aug 2020 15:19:29 +0300 Subject: [PATCH 11/13] style: after lint --- lib/options.js | 5 ++--- test/options/directives.test.js | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/options.js b/lib/options.js index fd3e9cc..09da1e7 100644 --- a/lib/options.js +++ b/lib/options.js @@ -1,15 +1,14 @@ 'use strict' module.exports = function parseOptions (params) { - let {plugins, ...options} = params; + let { plugins, ...options } = params if (typeof plugins === 'function') { plugins = plugins.call(this, this) } if (typeof plugins === 'undefined') plugins = [] - else if (Array.isArray(plugins)) plugins = plugins - else plugins = [plugins] + else if (!Array.isArray(plugins)) plugins = [plugins] return Promise.resolve({ options, plugins }) } diff --git a/test/options/directives.test.js b/test/options/directives.test.js index 971914f..3a10999 100644 --- a/test/options/directives.test.js +++ b/test/options/directives.test.js @@ -12,8 +12,8 @@ describe('Options', () => { directives: [{ name: '?php', start: '<', - end: '>', - }] + end: '>' + }] } } } From a189a5229910132ff28eca6f8b45db8daa4eb8eb Mon Sep 17 00:00:00 2001 From: Ivan Demidov Date: Fri, 21 Aug 2020 15:28:37 +0300 Subject: [PATCH 12/13] ci: dropp support old node --- .travis.yml | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 72d6657..ee6d51f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ language: node_js node_js: - stable - lts/* - - 8 + - 10 after_success: - cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js" diff --git a/package.json b/package.json index b5d2169..545bd93 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "version": "1.0.2", "main": "lib/index.js", "engines": { - "node": ">= 8" + "node": ">= 10" }, "files": [ "lib" From a0277cf7cfbcbe598adaac6f03c37d9a917875e4 Mon Sep 17 00:00:00 2001 From: Ivan Demidov Date: Fri, 21 Aug 2020 15:34:02 +0300 Subject: [PATCH 13/13] 2.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 545bd93..07be986 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "posthtml-loader", "description": "PostHTML for Webpack", - "version": "1.0.2", + "version": "2.0.0", "main": "lib/index.js", "engines": { "node": ">= 10"