open-wc / open-wc

Open Web Components: guides, tools and libraries for developing web components.
https://open-wc.org/
MIT License
2.25k stars 423 forks source link

HMR plugin for wc removes sourcemaps when used in dev server #2406

Open abbasc52 opened 2 years ago

abbasc52 commented 2 years ago

Expected behavior

HMR plugin should not remove sourcemaps for the files

Actual Behavior

When running Dev server for a Lit project, it renders sourcemaps but when HMR is enabled, it removes any sourcemap found in file.

Additional context

package.json dev dependency "@open-wc/dev-server-hmr": "next",

Looking closer into the package, i found it happens due to babel transform configuration in the plugin. If i manually include sourceMaps: "inline" in the file it starts working.

diff --git a/node_modules/@open-wc/dev-server-hmr/src/babel/babelTransform.js b/node_modules/@open-wc/dev-server-hmr/src/babel/babelTransform.js
index 25ec195..5897045 100644
--- a/node_modules/@open-wc/dev-server-hmr/src/babel/babelTransform.js
+++ b/node_modules/@open-wc/dev-server-hmr/src/babel/babelTransform.js
@@ -18,6 +18,7 @@ async function babelTransform(code, filename, options) {
       name: '@open-wc/dev-server-hmr',
       supportsStaticESM: true,
     },
+    sourceMaps: "inline",
     plugins: [
       [babelPluginWcHmr, options],
       require.resolve('@babel/plugin-syntax-class-properties'),

Is it intended?

majiangl commented 2 years ago

The same happened to me.