Skip to content

Commit

Permalink
Merge pull request #333 from ieedan/fix-vue-compiler-issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ieedan authored Jan 6, 2025
2 parents 689306c + 22b53f0 commit ae44f8b
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 15 deletions.
5 changes: 5 additions & 0 deletions .changeset/odd-tables-clean.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"jsrepo": patch
---

Ensure vue compiler has `fs` access.
11 changes: 11 additions & 0 deletions examples/registry/blocks/vue/Test.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<script setup lang="ts">
import type { PropType } from './type';
const props = defineProps<PropType>();
</script>

<template>
<div>
{{ value }}
</div>
</template>
1 change: 1 addition & 0 deletions examples/registry/blocks/vue/type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type PropType = { value: string };
39 changes: 39 additions & 0 deletions examples/registry/jsrepo-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -220,5 +220,44 @@
"devDependencies": []
}
]
},
{
"name": "vue",
"blocks": [
{
"name": "Test",
"directory": "blocks/vue",
"category": "vue",
"tests": false,
"subdirectory": false,
"list": true,
"files": [
"Test.vue"
],
"localDependencies": [
"vue/type"
],
"_imports_": {
"./type": "{{vue/type}}"
},
"dependencies": [],
"devDependencies": []
},
{
"name": "type",
"directory": "blocks/vue",
"category": "vue",
"tests": false,
"subdirectory": false,
"list": true,
"files": [
"type.ts"
],
"localDependencies": [],
"_imports_": {},
"dependencies": [],
"devDependencies": []
}
]
}
]
16 changes: 2 additions & 14 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,12 @@
"bugs": {
"url": "https://github.com/ieedan/jsrepo/issues"
},
"keywords": [
"repo",
"cli",
"svelte",
"vue",
"typescript",
"javascript",
"shadcn",
"registry"
],
"keywords": ["repo", "cli", "svelte", "vue", "typescript", "javascript", "shadcn", "registry"],
"type": "module",
"exports": "./dist/index.js",
"bin": "./dist/index.js",
"main": "./dist/index.js",
"files": [
"./schemas/**/*",
"dist"
],
"files": ["./schemas/**/*", "dist"],
"scripts": {
"start": "tsup --silent && node ./dist/index.js",
"build": "tsup",
Expand Down
9 changes: 8 additions & 1 deletion packages/cli/src/utils/language-support.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,14 @@ const vue: Lang = {

let compiled: v.SFCScriptBlock;
try {
compiled = v.compileScript(parsed.descriptor, { id: 'shut-it' }); // you need this id to remove a warning
compiled = v.compileScript(parsed.descriptor, {
id: 'shut-it',
fs: {
fileExists: fs.existsSync,
readFile: (file) => fs.readFileSync(file).toString(),
realpath: fs.realpathSync,
},
}); // you need this id to remove a warning
} catch (err) {
return Err(`Compile error: ${err}`);
}
Expand Down

0 comments on commit ae44f8b

Please sign in to comment.