Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions packages/puls-compiler/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,17 @@ function parseTemplateString(input: string) {
let buffer = "";
let insideExpression = false;
let insideString = false;
let braceCount = 0;
let braceCount = 0

for (let i = 0; i < input.length; i++) {


for (let i = 0; i < input.length; i++) {
if (!insideExpression) {
if (input[i] === "$" && input[i + 1] === "{") {
strings.push(buffer);
buffer = "";
insideExpression = true;
braceCount = 1;
i++; // Skip "{"
} else if (input[i] === "\\" && input[i + 1] === "$" && input[i + 2] === "{") {
buffer += "${";
i += 2;
Expand Down Expand Up @@ -101,7 +102,7 @@ export async function compile(r: string) {
const ts = await import('typescript')
const { outputText } = ts.transpileModule(scriptValue, {
compilerOptions: {
experimentalDecorators: true,
experimentalDecorators: false,
module: ts.ModuleKind.ESNext,
target: ts.ScriptTarget.ESNext,
moduleResolution: ts.ModuleResolutionKind.NodeJs,
Expand Down Expand Up @@ -133,17 +134,18 @@ export async function compile(r: string) {

const [strings, values] = parseTemplateString(other)
const second = templateStringParse(new TemplateParser(), strings as any, ...values).parse();

console.count()
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Remove debug statement.

Debug statements like console.count() should not be committed to production code.

-    console.count()
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
console.count()

return `${extractedImports}${hasHtmlImport ? '' : "\nimport { pulsInstance } from 'pulsjs';"}\n\nexport default ($props = {}) => {
\n ${scriptTag}\n \n return (new pulsInstance.adapter(${exportOutput(second)})).render();
}`;
}


export async function pulsPlugin() {
console.log('Example')
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Remove debug statement.

Debug statements like console.log('Example') should not be committed to production code.

-    console.log('Example')
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
console.log('Example')

return {
name: 'vite-plugin-puls',
transform: async (code: any, id: any) => {
transform: async x(code: any, id: any) => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix syntax error in transform function signature.

The current function signature is invalid and causing build failures. The x identifier is causing syntax errors.

-        transform: async x(code: any, id: any) => {
+        transform: async (code: any, id: any) => {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
transform: async x(code: any, id: any) => {
transform: async (code: any, id: any) => {
🧰 Tools
🪛 Biome (1.9.4)

[error] 148-148: expected , but instead found x

Remove x

(parse)


[error] 148-148: Expected a function body but instead found '=>'.

Expected a function body here.

(parse)

🪛 GitHub Check: build (20)

[failure] 148-148:
',' expected.


[failure] 148-148:
'{' expected.


[failure] 148-148:
Property assignment expected.


[failure] 148-148:
Cannot find name 'async'.

🪛 GitHub Actions: Test the build process

[error] 148-148: error TS1005: ',' expected.

if (!id.endsWith('.puls')) return null;
fs.writeFileSync('ex', code)

Expand Down