Skip to content

Commit a37701d

Browse files
fix: Inline source content in source maps to prevent Webpack warnings
Source maps now embed the original TypeScript source content directly, preventing Webpack's source-map-loader from throwing warnings about missing source files when consuming the package. Fixes #5549 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 7790e13 commit a37701d

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

rollup.config.mjs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,18 @@ const migrateRollup2to3OutputOptions = {
3838
interop: "compat",
3939
};
4040

41+
// Common sourcemap options to embed source content directly in the map
42+
// This prevents Webpack source-map-loader warnings about missing source files
43+
// See: https://github.com/Hacker0x01/react-datepicker/issues/5549
44+
/** @type {Partial<import('rollup').OutputOptions>} */
45+
const sourcemapOptions = {
46+
sourcemap: true,
47+
sourcemapExcludeSources: false,
48+
};
49+
4150
/** @type {import('rollup').RollupOptions} */
4251
const config = {
4352
input: "src/index.tsx",
44-
sourcemap: true,
4553
output: [
4654
{
4755
file: pkg.unpkg,
@@ -50,32 +58,32 @@ const config = {
5058
globals,
5159
banner,
5260
...migrateRollup2to3OutputOptions,
61+
...sourcemapOptions,
5362
plugins: [terser()],
54-
sourcemap: true,
5563
},
5664
{
5765
file: pkg.unpkg.replace(".min.js", ".js"),
5866
format: "umd",
59-
sourcemap: true,
6067
name: "DatePicker",
6168
globals,
6269
banner,
6370
...migrateRollup2to3OutputOptions,
71+
...sourcemapOptions,
6472
},
6573
{
6674
file: pkg.main,
6775
format: "cjs",
68-
sourcemap: true,
6976
name: "DatePicker",
7077
banner,
7178
...migrateRollup2to3OutputOptions,
79+
...sourcemapOptions,
7280
},
7381
{
7482
file: pkg.module,
7583
format: "es",
76-
sourcemap: true,
7784
banner,
7885
...migrateRollup2to3OutputOptions,
86+
...sourcemapOptions,
7987
},
8088
],
8189
plugins: [
@@ -89,6 +97,8 @@ const config = {
8997
tsconfig: "./tsconfig.build.json",
9098
declaration: true,
9199
declarationDir: "dist",
100+
sourceMap: true,
101+
inlineSources: true,
92102
}),
93103
filesize(),
94104
],

0 commit comments

Comments
 (0)