rw-elements-tools 1.3.0 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build-shared-hooks.js
CHANGED
|
@@ -116,42 +116,34 @@ async function buildOne(sharedFiles, sourcePath, projectRoot, minify = true) {
|
|
|
116
116
|
|
|
117
117
|
// Read the component source
|
|
118
118
|
let componentContent = await fs.promises.readFile(sourcePath, 'utf8');
|
|
119
|
+
const hasExportLine = /exports\.transformHook\s*=/.test(componentContent);
|
|
119
120
|
|
|
120
|
-
//
|
|
121
|
-
|
|
121
|
+
// Ensure the expected CommonJS export is present exactly once
|
|
122
|
+
if (!hasExportLine) {
|
|
123
|
+
componentContent = `${componentContent.trim()}\nexports.transformHook = transformHook;`;
|
|
124
|
+
}
|
|
122
125
|
|
|
123
|
-
// Concatenate everything
|
|
124
|
-
// esbuild will keep transformHook and anything it references, drop the rest
|
|
126
|
+
// Concatenate everything
|
|
125
127
|
const combinedSource = `
|
|
126
128
|
${sharedPieces.join('\n\n')}
|
|
127
129
|
|
|
128
130
|
${componentContent}
|
|
129
|
-
|
|
130
|
-
export { transformHook };
|
|
131
131
|
`;
|
|
132
132
|
|
|
133
|
-
//
|
|
134
|
-
// minifySyntax: true enables dead code elimination
|
|
135
|
-
// When minify=true, also minify whitespace and identifiers
|
|
133
|
+
// Minify whitespace only (keep identifier names); enable syntax minification for small size
|
|
136
134
|
const result = await transform(combinedSource, {
|
|
137
135
|
loader: 'js',
|
|
138
136
|
target: 'es2018',
|
|
139
|
-
minifySyntax:
|
|
140
|
-
minifyWhitespace: minify,
|
|
141
|
-
minifyIdentifiers:
|
|
142
|
-
format: '
|
|
137
|
+
minifySyntax: minify,
|
|
138
|
+
minifyWhitespace: minify,
|
|
139
|
+
minifyIdentifiers: false,
|
|
140
|
+
format: 'cjs',
|
|
143
141
|
legalComments: 'none',
|
|
144
142
|
});
|
|
145
143
|
|
|
146
|
-
let code = result.code;
|
|
147
|
-
|
|
148
|
-
// Replace ESM export with CommonJS-style assignment
|
|
149
|
-
code = code.replace(/export\s*\{\s*transformHook\s*(as\s+\w+)?\s*\}\s*;?\s*$/m, 'exports.transformHook = transformHook;');
|
|
150
|
-
|
|
151
|
-
// Only add banner in non-minified mode to save bytes
|
|
152
144
|
const banner = minify ? '' : `// AUTO-GENERATED: do not edit. Edit hooks.source.js instead.\n`;
|
|
153
145
|
|
|
154
|
-
await fs.promises.writeFile(outputPath, banner + code, 'utf8');
|
|
146
|
+
await fs.promises.writeFile(outputPath, banner + result.code, 'utf8');
|
|
155
147
|
|
|
156
148
|
console.log(`[hooks] Wrote ${path.relative(projectRoot, outputPath)}`);
|
|
157
149
|
}
|
|
@@ -145,19 +145,19 @@ const ButtonFontAndTextStyles = [
|
|
|
145
145
|
}
|
|
146
146
|
},
|
|
147
147
|
{
|
|
148
|
-
title: "
|
|
149
|
-
id: "
|
|
150
|
-
format: "
|
|
148
|
+
title: "Spacing",
|
|
149
|
+
id: "globalButtonFontAndTextStylesLetterSpacing",
|
|
150
|
+
format: "tracking-{{value}}",
|
|
151
151
|
slider: {
|
|
152
|
-
use: "
|
|
152
|
+
use: "LetterSpacing",
|
|
153
153
|
}
|
|
154
154
|
},
|
|
155
155
|
{
|
|
156
|
-
title: "
|
|
157
|
-
id: "
|
|
158
|
-
format: "
|
|
156
|
+
title: "Line Height",
|
|
157
|
+
id: "globalButtonFontAndTextStylesLineHeight",
|
|
158
|
+
format: "leading-{{value}}",
|
|
159
159
|
slider: {
|
|
160
|
-
use: "
|
|
160
|
+
use: "LineHeight",
|
|
161
161
|
}
|
|
162
162
|
},
|
|
163
163
|
{
|
package/package.json
CHANGED