@frozzare/pkg 1.0.4 → 1.0.6
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/dist/index.js +5 -4
- package/dist/utils.js +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -35,13 +35,14 @@ const build = async (entry, options = {}) => {
|
|
|
35
35
|
const file = result.outputFiles[0];
|
|
36
36
|
let text = file.text;
|
|
37
37
|
if (config.format === 'cjs') {
|
|
38
|
-
const
|
|
39
|
-
const match = text.match(reg);
|
|
38
|
+
const match = text.match(/.*default:(?:\s+|)\(\)(?:\s+|)=>(?:\s+|)([A-Za-z0-9_]+)/);
|
|
40
39
|
if (!match) {
|
|
41
40
|
throw new Error('Failed to find export name');
|
|
42
41
|
}
|
|
43
|
-
const name = match === null || match === void 0 ? void 0 : match[1].
|
|
44
|
-
text =
|
|
42
|
+
const name = match === null || match === void 0 ? void 0 : match[1].trim();
|
|
43
|
+
text =
|
|
44
|
+
text.replace(/module.exports = __toCommonJS\(\w+\);/, '') +
|
|
45
|
+
`module.exports = ${name};`.replace((config === null || config === void 0 ? void 0 : config.minify) ? /\s/g : '', '');
|
|
45
46
|
}
|
|
46
47
|
if (!config.write) {
|
|
47
48
|
return text;
|
package/dist/utils.js
CHANGED