You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+33-1Lines changed: 33 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,7 @@
14
14
<ahref="#setup">Setup</a> ✯
15
15
<ahref="#formats">Formats</a> ✯
16
16
<ahref="#modern">Modern Mode</a> ✯
17
+
<ahref="#debug">Debug Mode</a> ✯
17
18
<ahref="#usage">Usage & Configuration</a> ✯
18
19
<ahref="#options">All Options</a>
19
20
</p>
@@ -144,6 +145,36 @@ The `"exports"` field can also be an object for packages with multiple entry mod
144
145
}
145
146
```
146
147
148
+
## 🐛 Debug Mode <aname="debug"></a>
149
+
150
+
Microbundle can generate an **unminified debug build** to help with debugging your library. This is useful when you need to step through your bundled code or investigate issues in production builds.
151
+
152
+
To enable debug mode, simply add a `"debug"` field to your `package.json`:
153
+
154
+
```jsonc
155
+
{
156
+
"name":"foo",
157
+
"source":"src/index.js",
158
+
"main":"./dist/foo.js",
159
+
"module":"./dist/foo.module.js",
160
+
"debug":"./dist/foo.debug.js", // 👈 Add this field
161
+
"scripts": {
162
+
"build":"microbundle"
163
+
}
164
+
}
165
+
```
166
+
167
+
When the `debug` field is present, Microbundle will automatically generate an additional unminified bundle with:
168
+
169
+
-**Modern ES2017+ syntax** (same as the `modern` format - async/await, arrow functions, etc.)
170
+
-**No minification** - readable code with preserved variable names
171
+
-**Preserved comments** - your code comments remain in the output
172
+
-**Proper formatting** - whitespace and indentation maintained
173
+
174
+
This makes it much easier to debug issues in your library code without needing to map back through source maps.
175
+
176
+
> 💡 **Tip**: The debug build is automatically included when the `debug` field exists - no need to modify the `--format` flag.
177
+
147
178
## 📦 Usage & Configuration <aname="usage"></a>
148
179
149
180
Microbundle includes two commands - `build` (the default) and `watch`.
@@ -172,7 +203,8 @@ The filenames and paths for generated bundles in each format are defined by the
exports[`fixtures build debug with microbundle 4`] =`
1794
+
"var r=function(r){try{return Promise.resolve(fetch(\\"/api/users/\\"+r)).then(function(r){returnPromise.resolve(r.json())})}catch(r){return Promise.reject(r)}},e=function(r,e){return\\"Hello, \\"+r+\\"! You are \\"+e+\\" years old.\\"},t=/*#__PURE__*/function(){function e(r){void0===r&&(r=[]),this.users=r,this.count=r.length}vart=e.prototype;returnt.addUser=function(r){this.users.push(r),this.count++},t.loadUsers=function(){try{returnPromise.resolve(Promise.all(this.users.map(function(e){returnr(e.id)})))}catch(r){returnPromise.reject(r)}},e}();export{tasUserManager,eascreateGreeting,rasfetchUserData};
1795
+
//# sourceMappingURL=debug-lib.esm.mjs.map
1796
+
"
1797
+
`;
1798
+
1799
+
exports[`fixtures build debug with microbundle 5`] =`
1800
+
"var e=function(e){try{return Promise.resolve(fetch(\\"/api/users/\\"+e)).then(function(e){returnPromise.resolve(e.json())})}catch(e){return Promise.reject(e)}};exports.UserManager=/*#__PURE__*/function(){function r(e){void0===e&&(e=[]),this.users=e,this.count=e.length}vart=r.prototype;returnt.addUser=function(e){this.users.push(e),this.count++},t.loadUsers=function(){try{returnPromise.resolve(Promise.all(this.users.map(function(r){returne(r.id)})))}catch(e){returnPromise.reject(e)}},r}(),exports.createGreeting=function(e,r){return\\"Hello, \\"+e+\\"! You are \\"+r+\\" years old.\\"},exports.fetchUserData=e;
1801
+
//# sourceMappingURL=debug-lib.js.map
1802
+
"
1803
+
`;
1804
+
1805
+
exports[`fixtures build debug with microbundle 6`] =`
1806
+
"!function(e,t){\\"object\\"==typeofexports&&\\"undefined\\"!=typeofmodule?t(exports):\\"function\\"==typeofdefine&&define.amd?define([\\"exports\\"],t):t((e||self).debugLib={})}(this,function(e){vart=function(e){try{returnPromise.resolve(fetch(\\"/api/users/\\"+e)).then(function(e){returnPromise.resolve(e.json())})}catch(e){returnPromise.reject(e)}};e.UserManager=/*#__PURE__*/function(){function e(e){void0===e&&(e=[]),this.users=e,this.count=e.length}var r=e.prototype;returnr.addUser=function(e){this.users.push(e),this.count++},r.loadUsers=function(){try{returnPromise.resolve(Promise.all(this.users.map(function(e){returnt(e.id)})))}catch(e){returnPromise.reject(e)}},e}(),e.createGreeting=function(e,t){return\\"Hello, \\"+e+\\"! You are \\"+t+\\" years old.\\"},e.fetchUserData=t});
1807
+
//# sourceMappingURL=debug-lib.umd.js.map
1808
+
"
1809
+
`;
1810
+
1726
1811
exports[`fixtures build default-named with microbundle 1`] =`
0 commit comments