-
Notifications
You must be signed in to change notification settings - Fork 1
handling some gaps in compilation #1
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,18 +5,22 @@ import esbuild from 'esbuild'; | |
| import compiler from '../constants.js' | ||
|
|
||
| const outdir = path.join(process.cwd(), 'public', 'media'); | ||
| const mediaGlobs = '*.+(jpg|jpeg|png|gif|webp|svg|ico)'; | ||
| const mediaGlobs = '*.+(jpg|jpeg|png|gif|webp|svg|ico|js)'; | ||
| const modules = { | ||
| components: { | ||
| path: path.join(process.cwd(), 'components'), | ||
| src: globby(path.join(process.cwd(), 'components', '**', 'media', mediaGlobs)), | ||
| }, | ||
| layouts: { | ||
| path: path.join(process.cwd(), 'layouts'), | ||
| src: globby(path.join(process.cwd(), 'layouts', '**', 'media', mediaGlobs)), | ||
| }, | ||
| sites: { | ||
| path: path.join(process.cwd(), 'sites'), | ||
| src: globby([ | ||
| path.join(process.cwd(), 'sites', '**', 'media', mediaGlobs), | ||
| ]), | ||
| } | ||
| }, | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -82,6 +86,7 @@ const mediaConfig = { | |
| '.png': 'copy', | ||
| '.svg': 'copy', | ||
| '.webp': 'copy', | ||
| '.js': 'copy', | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. slate codebase includes some
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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! 🙂
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looking into this more closely will create an issue
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| }, | ||
| logLevel: compiler.logLever, | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -268,13 +268,11 @@ async function processModule(filePath, cachedIds, registry, ids, envs) { | |
| let prependContent = `window.modules["${moduleId}"] = [function(require,module,exports){`; | ||
| let appendContent = ''; | ||
|
|
||
| const fileName = `${moduleId}.js`; | ||
|
|
||
| // compile vue to JS before creating the magic string | ||
| if (isVue) { | ||
| try { | ||
| const vueSFC = await vueSfcHandler({ | ||
| filename: fileName, | ||
| filename: filePath, | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup, making this change fixed the issue for Slate! |
||
| source: code, | ||
| extractCss: true, | ||
| production: false, | ||
|
|
@@ -319,6 +317,14 @@ async function processModule(filePath, cachedIds, registry, ids, envs) { | |
| } | ||
| } | ||
|
|
||
| if (!isJson) { | ||
| const transformed = await esbuild.transform(code, { | ||
| format: 'cjs', | ||
| target: 'es2015' | ||
| }); | ||
| code = transformed.code; | ||
| } | ||
|
|
||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure if this is where this should go, but was getting
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 // 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.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe we can do some replacement to
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| // magic-string for file content manipulation | ||
| const s = new MagicString(code); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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