Skip to content

Commit 0c73e49

Browse files
committed
fix: rollup
1 parent 9263068 commit 0c73e49

1 file changed

Lines changed: 0 additions & 86 deletions

File tree

configs/jsactions/rollup.config.mjs

Lines changed: 0 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -39,91 +39,6 @@ export default async args => {
3939

4040
const copyAsync = promisify(copy);
4141

42-
// Inline plugin to prepare JS actions for Studio Pro format
43-
const studioProFormatPlugin = {
44-
name: "studio-pro-format",
45-
generateBundle(options, bundle) {
46-
for (const [fileName, chunk] of Object.entries(bundle)) {
47-
if (chunk.type !== "chunk" || !fileName.endsWith(".js")) continue;
48-
49-
let code = chunk.code;
50-
51-
// 1. Check if header exists and remove it (we'll add it back at line 1)
52-
const hasHeader = code.includes("// This file was generated by Mendix Studio Pro.");
53-
if (hasHeader) {
54-
// Remove existing header (7 lines)
55-
code = code.replace(
56-
/^\/\/ This file was generated by Mendix Studio Pro\.\r?\n\/\/\r?\n\/\/ WARNING: Only the following code will be retained when actions are regenerated:\r?\n\/\/ - the import list\r?\n\/\/ - the code between BEGIN USER CODE and END USER CODE\r?\n\/\/ - the code between BEGIN EXTRA CODE and END EXTRA CODE\r?\n\/\/ Other code you write will be lost the next time you deploy the project\.\r?\n/m,
57-
""
58-
);
59-
}
60-
61-
// 2. Remove Big import (will add back at line 8 with header)
62-
const hasBigImport = code.match(/^import\s*\{\s*Big\s*\}\s*from\s*["']big\.js["'];?\s*$/m);
63-
if (hasBigImport) {
64-
code = code.replace(/^import\s*\{\s*Big\s*\}\s*from\s*["']big\.js["'];?\s*\r?\n/m, "");
65-
}
66-
67-
// 3. Add header at line 1 + Big import at line 8
68-
const header = [
69-
"// This file was generated by Mendix Studio Pro.",
70-
"//",
71-
"// WARNING: Only the following code will be retained when actions are regenerated:",
72-
"// - the import list",
73-
"// - the code between BEGIN USER CODE and END USER CODE",
74-
"// - the code between BEGIN EXTRA CODE and END EXTRA CODE",
75-
"// Other code you write will be lost the next time you deploy the project.",
76-
'import { Big } from "big.js";'
77-
].join("\r\n") + "\r\n";
78-
79-
code = header + code;
80-
81-
// 4. Add missing // BEGIN EXTRA CODE if // END EXTRA CODE exists without a BEGIN
82-
if (code.includes('// END EXTRA CODE') && !code.includes('// BEGIN EXTRA CODE')) {
83-
// Find last import line, add BEGIN EXTRA CODE after it
84-
code = code.replace(/(^import .+$)/m, '$1\n\n// BEGIN EXTRA CODE');
85-
}
86-
87-
// 5. If no EXTRA CODE markers at all, add empty block after imports
88-
if (!code.includes('// BEGIN EXTRA CODE') && !code.includes('// END EXTRA CODE')) {
89-
code = code.replace(/(^import .+$)(\r?\n)+(?=\/?\*\*|export)/m, '$1\n\n// BEGIN EXTRA CODE\n// END EXTRA CODE\n\n');
90-
}
91-
92-
// 6. Fix export pattern: async function Name { } export { Name };
93-
// → export async function Name { }
94-
const exportMatch = code.match(/export\s*\{\s*(\w+)\s*\};?\s*$/m);
95-
if (exportMatch) {
96-
const functionName = exportMatch[1];
97-
const funcPattern = new RegExp(`^(async\\s+function\\s+${functionName}\\s*\\()`, "m");
98-
code = code.replace(funcPattern, "export $1");
99-
code = code.replace(/\nexport\s*\{\s*\w+\s*\};?\s*$/m, "");
100-
}
101-
102-
// 7. Fix USER CODE marker indentation: Studio Pro uses tabs inside functions
103-
// Match any whitespace before the markers and replace with single tab
104-
code = code.replace(/^[ \t]+(\/\/ BEGIN USER CODE)/gm, "\t$1");
105-
code = code.replace(/^[ \t]+(\/\/ END USER CODE)/gm, "\t$1");
106-
107-
// 8. Ensure blank line before // BEGIN EXTRA CODE
108-
code = code.replace(/([^\r\n])\r?\n(\/\/ BEGIN EXTRA CODE)/g, "$1\r\n\r\n$2");
109-
110-
// 9. Ensure blank line after // END EXTRA CODE
111-
code = code.replace(/(\/\/ END EXTRA CODE)\r?\n([^\r\n])/g, "$1\r\n\r\n$2");
112-
113-
// 10. Normalize JSDoc formatting to match Studio Pro
114-
// - Empty JSDoc lines: ` *` (one space before asterisk, nothing after)
115-
// - Lines with text: ` * text` (one space before, one space after asterisk)
116-
code = code.replace(/^[ \t]+\*[ \t]+$/gm, " *"); // Empty JSDoc lines: remove trailing whitespace
117-
code = code.replace(/^[ \t]+\*[ \t]+(.+)$/gm, " * $1"); // JSDoc with text: normalize to 1 space before and after asterisk
118-
119-
// 11. Normalize all line endings to CRLF (Studio Pro expects \r\n everywhere)
120-
code = code.replace(/\r?\n/g, "\r\n");
121-
122-
chunk.code = code;
123-
}
124-
}
125-
};
126-
12742
files.forEach((file, i) => {
12843
const fileInput = relative(cwd, file);
12944
const fileOutput = basename(file, ".ts");
@@ -159,7 +74,6 @@ export default async args => {
15974
}),
16075
nodeResolvePlugin,
16176
typescriptPlugin,
162-
studioProFormatPlugin,
16377
i === files.length - 1
16478
? command([
16579
async () => copyLicenseFile(cwd, outDir),

0 commit comments

Comments
 (0)