Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

svelte-style html files #46

Open
brumm opened this issue Sep 11, 2018 · 3 comments
Open

svelte-style html files #46

brumm opened this issue Sep 11, 2018 · 3 comments

Comments

@brumm
Copy link

brumm commented Sep 11, 2018

Hey,

I'm trying to extract dependencies from a svelte-style .html file.
It seems like precinct is trying to parse it like JSX:

❯ env DEBUG=precinct npx precinct svelte/HelloWorld.html
  precinct options given:  { es6: {} } +0ms
  precinct could not parse content: Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...</>? (7:0) +8ms
[]

This is the file content:

<div class="container">
	<h1>Hello {name}!</h1>

	<EditingMessage></EditingMessage>
</div>

<style>
	.container {
		text-align: center;
		margin-top: 2rem;

		font-family: sans-serif;
	}
</style>

<script>
	import EditingMessage from './EditingMessage.html';

	export default {
		components: { EditingMessage }
	}
</script>

I think vue single file components look quite similarly.

I may have some time later this week to look into this myself, just wanted to document this somewhere.

@mrjoelkemp
Copy link
Collaborator

Thanks for filing @brumm.

There's no detective-html at the moment, but it would be cool to have one to serve your desired purpose. It could be as simple as only supporting embedded es6 instead of handling all module formats embedded in html. If you could somehow extract the JS code, generate the JS AST, then that could be used wholesale in filing-cabinet to resolve the imported modules for use in dependency-tree.

If you want to tackle creating the detective-html package, I'd be very open to having it used within precinct.

An aside: I don't think the precinct cli sets any of the supported precinct options, so beware when using that.

@brumm
Copy link
Author

brumm commented Sep 15, 2018 via email

@maxim-usikov
Copy link

Any news? Want this for vue

ZhenyuCheng pushed a commit to ZhenyuCheng/node-precinct that referenced this issue Dec 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants