Skip to content

Using with async plugins like posthtml-fetch #21

@cossssmin

Description

@cossssmin

Hey, thanks so much for creating this, I'm currently testing it in Maizzle as a replacement for posthtml-modules.

Tried using it with posthtml-fetch:

const posthtml = require('posthtml')
const fetchPlugin = require('posthtml-fetch')
const components = require('posthtml-component')

posthtml([
  components({
    root: './',
    folders: ['src'],
    tagName: 'component',
    attribute: 'src',
    yield: 'content',
    expressions: {strictMode: false},
    plugins: [
      fetchPlugin()
    ],
  }),
])

... but I get a TypeError:

TypeError: tree.match is not a function
    at F:\DEV\x\node_modules\posthtml-fetch\lib\index.js:19:10     
    at new Promise (<anonymous>)
    at F:\DEV\x\node_modules\posthtml-fetch\lib\index.js:16:10     
    at F:\DEV\x\node_modules\posthtml-component\src\index.js:272:12
    at Array.reduce (<anonymous>)
    at applyPluginsToTree (F:\DEV\x\node_modules\posthtml-component\src\index.js:271:18)
    at F:\DEV\x\node_modules\posthtml-component\src\index.js:156:14
    at F:\DEV\x\node_modules\posthtml-component\src\index.js:129:27
    at err (F:\DEV\x\node_modules\posthtml\lib\index.js:219:34)    
    at tryCatch (F:\DEV\x\node_modules\posthtml\lib\index.js:300:12

Any way we can get them to work?

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions