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

Component name sanitisation #102

Closed
antony opened this issue Dec 3, 2016 · 2 comments
Closed

Component name sanitisation #102

antony opened this issue Dec 3, 2016 · 2 comments
Labels
Milestone

Comments

@antony
Copy link
Member

antony commented Dec 3, 2016

I'm building svelte components dynamically, and part of this process is an intermediate file called .compiled.html which is essentially a svelte component built from a series of files.

What I'm seeing is that the compiled component adopts this intermediate filename as the exported module name. As you can imagine .compiled is not a valid Javascript variable name:

function .compiled ( options ) { // invalid variable name
	var component = this;
...
.compiled.prototype = template.methods;

export default .compiled;

This is an easy fix for me as I can simply specify the filename. However, I'd probably suggest that when I run:

svelte compile ./.compiled.html

that the default name is sanitized and either throws an error or is stripped of illegal characters during component generation.

@Rich-Harris
Copy link
Member

Ah, excellent point. In the meantime, you should be able to fix that by manually specifying a --name (otherwise it's guessed from the filename).

@Rich-Harris
Copy link
Member

As of 1.3.1 Svelte will throw if options.name is illegal, and the latest version of the CLI will sanitize names beforehand

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants