posthtml / posthtml-cli

CLI for PostHTML
MIT License
28 stars 18 forks source link

fix: require of plugin that exports ES module #293

Closed jirutka closed 4 years ago

jirutka commented 4 years ago

Transpiled ES modules don’t export the default export directly as CommonJS modules, they always export an object and the default export is under the key "default" in this object.

Example of error message when plugin compiled as ES module (posthtml-hash):

node_modules/posthtml-cli/lib/cli.js:23
    require(plugin)(config.plugins[plugin])
                   ^

TypeError: require(...) is not a function
    at Object.keys.map.plugin (node_modules/posthtml-cli/lib/cli.js:23:20)
    at Array.map (<anonymous>)
    at getPlugins (node_modules/posthtml-cli/lib/cli.js:21:4)
    at Object.<anonymous> (node_modules/posthtml-cli/lib/cli.js:26:1)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:829:12)
jirutka commented 4 years ago

CI fails only on lts/* and it doesn’t seem to be caused by this change.

Scrum commented 4 years ago

@jirutka Hi, thanks, I restarted the job and now everything is fine.

Scrum commented 4 years ago

@jirutka ping ?

Scrum commented 4 years ago

@jirutka thanks, now all is well

Scrum commented 4 years ago

@jirutka publish v0.5.3