Doesn't work with node on Windows because of process.env.PWD
lawliet29 opened this issue · comments
Alex Kurochkin commented
The plugin breaks on parsing Markdown files on Windows machine with the following error (full paths omitted):
× ...\src\...\page.md: The "path" argument must be of type string. Received type undefined
at assertPath (path.js:39:11)
at Object.parse (path.js:910:5)
at Resolver.findPackage (...\node_modules\parcel-plugin-markdown-string\node_modules\parcel-bundler\src\Resolver.js:419:21)
at MarkdownAsset.parse (...\node_modules\parcel-plugin-markdown-string\MarkdownAsset.js:10:37)
at MarkdownAsset.parseIfNeeded (...\node_modules\parcel-plugin-markdown-string\node_modules\parcel-bundler\src\Asset.js:63:29)
The problem is env.PWD
- apparently, it's always undefined
on non-*NIX systems; process.cwd()
can be used instead.
I was able to fix the issue by using patch-package
with the following change in MarkdownAsset.js
:
class MarkdownAsset extends Asset {
this.type = 'js';
}
async parse(markdownString) {
- const pkg = await this.resolver.findPackage(this.options.env.PWD);
+ const pkg = await this.resolver.findPackage(process.cwd());
if (pkg && pkg.marked) {
this.code = marked(markdownString, pkg.marked);
} else {
Might as well submit a pull request with this fix, if you want :)
小弟调调 commented
released parcel-plugin-markdown-string@1.3.4
@lawliet29 thx!