withastro / astro

The web framework for content-driven websites. ⭐️ Star to support our work!
https://astro.build
Other
46.82k stars 2.49k forks source link

🐛 BUG: Markdown content property crashes #933

Closed amatiasq closed 3 years ago

amatiasq commented 3 years ago

What package manager are you using?

npm

What operating system are you using?

Mac

Describe the Bug

Whenever I try to use the <Markdown content="anything"></Markdown> it crashes

Steps to Reproduce

git clone git@github.com:amatiasq/astro-bug-markdown-content.git
cd astro-bug-markdown-content
npm i
npm start

Expected behaviour

It should render index page with Test in a <h1>

Actual result

[14:10:26] [snowpack] File changed: src/pages/index.astro
[access] /
[14:10:29] [snowpack] Build Result Error: There was a problem with a file build result.
[executing astro] Error: Parse error @:1:1
    at parse (/Users/xxx/astro-bug-markdown-content-property/node_modules/snowpack/node_modules/es-module-lexer/dist/lexer.cjs:1:402)
    at scanCodeImportsExports (/Users/xxx/astro-bug-markdown-content-property/node_modules/snowpack/lib/cjs/rewrite-imports.js:21:29)
    at transformEsmImports (/Users/xxx/astro-bug-markdown-content-property/node_modules/snowpack/lib/cjs/rewrite-imports.js:37:27)
    at Object.transformFileImports (/Users/xxx/astro-bug-markdown-content-property/node_modules/snowpack/lib/cjs/rewrite-imports.js:108:16)
    at FileBuilder.resolveImports (/Users/xxx/astro-bug-markdown-content-property/node_modules/snowpack/lib/cjs/build/file-builder.js:116:48)
    at async Object.loadUrl (/Users/xxx/astro-bug-markdown-content-property/node_modules/snowpack/lib/cjs/commands/dev.js:640:39)
    at async load (/Users/xxx/astro-bug-markdown-content-property/node_modules/snowpack/lib/cjs/commands/dev.js:217:28)
    at async /Users/xxx/astro-bug-markdown-content-property/node_modules/snowpack/lib/cjs/ssr-loader/index.js:60:28
    at async Object.importModule (/Users/xxx/astro-bug-markdown-content-property/node_modules/snowpack/lib/cjs/ssr-loader/index.js:165:26)
    at async load (file:///Users/xxx/astro-bug-markdown-content-property/node_modules/astro/dist/runtime.js:76:17)
    at async Server.<anonymous> (file:///Users/xxx/astro-bug-markdown-content-property/node_modules/astro/dist/dev.js:21:20) {
  idx: 0
}
[access] /500

Link to Minimal Reproducible Example (Optional)

https://github.com/amatiasq/astro-bug-markdown-content

amatiasq commented 3 years ago

The same happens with self closing tags <Markdown content="# Test" />

I tried adding console.log() to node_modules/astro/components/Markdown.astro and running npx astro --reload but couldn't get the logs to print.

usirg commented 3 years ago

Just started with Astro and ran into this today. Maybe I overlooked something?

This is a slightly modified version of the Astro codesandbox:

I would consider this a fairly important issue as injecting markdown from external sources is probably a pretty common use case.

matthewp commented 3 years ago

Thanks! After taking a look, the problem is not in the Markdown component but in the compiler. Marking this as to be fixed in the new compiler.

amatiasq commented 3 years ago

This is actually blocking me from using Astro, do we know when the new compiler might be delivered?

usirg commented 3 years ago

@matthewp, thanks for following up on this! I had a look at the compiler-v2 repo and from the looks of it this is still quite a while out and not even sure to become astro's future compiler. Could you comment on how probable you think the v2 compiler will actually become the new compiler for astro and when that might happen. Assuming this might be a while, is there any chance of getting this bug fixed in the current compiler?

It would be very helpful to be able to use the markdown component with remote markdown, e.g. for being able to use expressions (which I hope is possible)

FredKSchott commented 3 years ago

We're targeting a mid-September for our first preview release using the new compiler, landing in npm install astro by October at the latest.

usirg commented 3 years ago

@FredKSchott, many thanks for the update, looking forward to it!

natemoo-re commented 3 years ago

It took us a lot longer than we expected, but astro@next has been merged to main and is now in preview!

This is definitely fixed in that version. See working reproduction!

natemoo-re commented 3 years ago

Following up on my previous comment, the team has decided to close out issues that have been confirmed as fixed by astro@0.21.0-next.0, astro@0.21.0-next.1, or astro@0.21.0-next.2. Our hope is that this will help the v0.21 milestone remain as actionable as possible.

To verify that this issue has been fixed, you may

If you think we made a mistake, please reopen this issue!

If you run into any other problems with astro@next, please open a new issue.