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

Build breaks if you there is a default export with a template literal #60

Open
Artur- opened this issue Feb 16, 2023 · 3 comments
Open

Comments

@Artur-
Copy link

Artur- commented Feb 16, 2023

const foo = `hello`;
export default foo;

If this gets passed through the plugin, it breaks with

error during build:
TypeError: Cannot read properties of undefined (reading 'replace')
    at escape (/.../vite.config.ts:605:27)
    at /.../vite.config.ts:636:53
    at walk (/.../node_modules/.pnpm/[email protected]/node_modules/dash-ast/index.js:69:28)
    at walkArray (/.../node_modules/.pnpm/[email protected]/node_modules/dash-ast/index.js:74:27)

If you change

const foo = `hello`;

to

const foo = "hello";

then it works.

The problem is because of https://github.com/umbopepato/rollup-plugin-postcss-lit/blob/main/index.ts#L68 assumes a default export initialized node has a .value which a template literal does not have

umbopepato added a commit that referenced this issue Jun 21, 2023
@umbopepato
Copy link
Owner

umbopepato commented Jun 21, 2023

Hey @Artur-! Version v2.1.0 is out with improved support for template literals. Please let me know if it works

@Artur-
Copy link
Author

Artur- commented Jun 27, 2023

Thanks but I don't think we can remove our custom version and upgrade because of #53/#54

@umbopepato
Copy link
Owner

I see. I was looking for a way to conciliate your PR with template literals support (it took a bit of experimentation with the different AST nodes). I think I found a way which seems to work but to be honest I haven't been able to reproduce your issue with composed URLs. Would you mind having a go with the Artur--vite3-support branch and let me know if it works?

Thanks for the patience!

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

No branches or pull requests

2 participants