Skip to content

Conversation

@reubenson
Copy link

@reubenson reubenson commented Sep 8, 2025

This PR contains tentative changes I've made that resolved compilation errors on the Slate instance of Clay. However, I'm not certain all these changes need to be made, or if there are more elegant ways of approaching

'.png': 'copy',
'.svg': 'copy',
'.webp': 'copy',
'.js': 'copy',
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slate codebase includes some .js assets in the media directory that could get handled this way

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, I'm wondering how those files are getting picked up and bundled by claycli as the .js extension is not listed here. Do these JS files in component's media dir require post-processing, or is simply copying them enough?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh good point. i see now that we're handling the copy-over of .js files in /media in a separate gulpfile, and not relying on clay cli. in our use case, these assets are meant to be self-contained scripts to be served as-is without need for post-processing. handling the js use case would be nice for keeping that sort of thing out of the component template file (i think)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I can see the value in that. Please let me know when the PR is ready for review! 🙂

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! i haven't had a chance yet to dig much into the edit mode issue - is that something you were seeing at all in local dev/testing?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no! edit mode works on our end, even in watch mode. Can you please create an issue with steps on how to reproduce?

Copy link
Author

@reubenson reubenson Sep 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking into this more closely will create an issue

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrote up an issue here, but let me know if you're unable to reproduce the issue
#2

layouts: {
path: path.join(process.cwd(), 'layouts'),
src: globby(path.join(process.cwd(), 'layouts', '**', 'media', mediaGlobs)),
},
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't seeing layout assets get processed, but maybe I'm missing some other flag to toggle that on?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch. I missed that, and claycli definitely handles layout media files

@reubenson reubenson marked this pull request as draft September 9, 2025 16:51
@reubenson
Copy link
Author

Noting page size comparisons with the old vs new compiler. Not a large sample size, but here are the results for the Slate homepage and an article page. Measurements were taken by saving the page to disk and looking at the resulting filesizes.

Homepage

Edit mode before: 5.3 MB
Edit mode after: 5.5 MB
Preview mode before: 921 kb
Preview mode after: 935 kb

Article page

Edit mode before: 5.3 MB
Edit mode after: 5.2 MB
Preview mode before: 980 kb
Preview mode after: 533 kb

In general page sizes have remained the same with the exception of the article in preview mode getting significantly smaller. More testing needs to be done, but if this is true, would be a great improvement for both us and our readers!

try {
const vueSFC = await vueSfcHandler({
filename: fileName,
filename: filePath,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was getting an error processing assets in vue files like here, which filePath resolves. but maybe then breaks your use case?

<style lang="scss">
@use "../../../global/scss/utility/_visibility.scss" as visibility;

Copy link
Member

@ealcantara22 ealcantara22 Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, this is a new one. We're using postcss which is a different step so, maybe that's why we're not affected. Anyway, are you saying that replacing that line fixed the issue for you?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, making this change fixed the issue for Slate!

});
code = transformed.code;
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if this is where this should go, but was getting Unexpected "export" errors

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi, sorry about the delay. Yes, this is a known issue. I don't know how Browserify and Vuetify detect and resolve these cases. The issue happens when you require a .js service which content is exported using ESM from a .vue file.

// my-service.js
export { ... }
// my-vue-component.vue
const myService = require('../services/my-service');

I gave up on this one back then because we only had to change like 3 or 4 JS files.
Changing export to module.exports should fix it, but let me know if you would rather find the root cause of this issue.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can do some replacement to .js files similar to what we do with .vue files here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm good with either solution (can make the change to module.exports), but I think we may as well have the explicit cjs transform. I'm also cool with not making this change for now and moving it to backlog if it comes up again later

@reubenson reubenson marked this pull request as ready for review September 18, 2025 18:43
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

Successfully merging this pull request may close these issues.

2 participants