ianstormtaylor / superstruct

A simple and composable way to validate data in JavaScript (and TypeScript).

Home Page:https://docs.superstructjs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Source maps seem broken

matthias-ccri opened this issue · comments

I'm seeing warnings from webpack in my browser console:

[webpack-dev-server] WARNING in ../../node_modules/superstruct/dist/index.mjs
Module Warning (from ../../node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/user/src/project/node_modules/superstruct/src/error.ts' file: Error: ENOENT: no such file or directory, open '/home/user/src/project/node_modules/superstruct/src/error.ts'
[webpack-dev-server] WARNING in ../../node_modules/superstruct/dist/index.mjs
Module Warning (from ../../node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/user/src/project/node_modules/superstruct/src/struct.ts' file: Error: ENOENT: no such file or directory, open '/home/user/src/project/node_modules/superstruct/src/struct.ts'
[webpack-dev-server] WARNING in ../../node_modules/superstruct/dist/index.mjs
Module Warning (from ../../node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/user/src/project/node_modules/superstruct/src/structs/coercions.ts' file: Error: ENOENT: no such file or directory, open '/home/user/src/project/node_modules/superstruct/src/structs/coercions.ts'
[webpack-dev-server] WARNING in ../../node_modules/superstruct/dist/index.mjs
Module Warning (from ../../node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/user/src/project/node_modules/superstruct/src/structs/refinements.ts' file: Error: ENOENT: no such file or directory, open '/home/user/src/project/node_modules/superstruct/src/structs/refinements.ts'
[webpack-dev-server] WARNING in ../../node_modules/superstruct/dist/index.mjs
Module Warning (from ../../node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/user/src/project/node_modules/superstruct/src/structs/types.ts' file: Error: ENOENT: no such file or directory, open '/home/user/src/project/node_modules/superstruct/src/structs/types.ts'
[webpack-dev-server] WARNING in ../../node_modules/superstruct/dist/index.mjs
Module Warning (from ../../node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/user/src/project/node_modules/superstruct/src/structs/utilities.ts' file: Error: ENOENT: no such file or directory, open '/home/user/src/project/node_modules/superstruct/src/structs/utilities.ts'
[webpack-dev-server] WARNING in ../../node_modules/superstruct/dist/index.mjs
Module Warning (from ../../node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/user/src/project/node_modules/superstruct/src/utils.ts' file: Error: ENOENT: no such file or directory, open '/home/user/src/project/node_modules/superstruct/src/utils.ts'

The index.mjs file has //# sourceMappingURL=index.mjs.map at the bottom which looks fine, however...

Here are the contents of index.mjs.map:

{"version":3,"file":"index.mjs","sources":["../src/error.ts","../src/utils.ts","../src/struct.ts","../src/structs/utilities.ts","../src/structs/types.ts","../src/structs/coercions.ts","../src/structs/refinements.ts"],"sourcesContent":[null,null,null,null,null,null,null],"names":[],"mappings":"AAAA;;AAEG;AAaH;;;;;;;AAOG;AAEG,MAAO,WAAY,SAAQ,SAAS,CAAA;IAUxC,WAAY,CAAA,OAAgB,EAAE,QAAkC,EAAA;AAC9D,QAAA,IAAI,MAAkC,CAAA;QACtC,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAA;AACjD,QAAA,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAA;QACxB,MAAM,GAAG,GACP,IAAI,CAAC,MAAM,KAAK,CAAC,GAAG,OAAO,GAAG,CAAA,SAAA,EAAY,IAAI,...

These reference paths like ../src/error.ts, but there is no src folder in the package as of v1.0.3, which seems to cause the warnings.

This is a huge blocker, unsure how its not a problem for more

@dimitrisnl this issue is more about the warnings being produced, this isn't a blocker for functionality. those warnings shouldn't prevent anything from running correctly. (I'm not sure why they're being produced but just elaborating)

I found a workaround: Add this to the webpack config:

        ignoreWarnings: [
            /Failed to parse source map/,
        ],

For me it didn't let me analyze the bundle using source-map-explorer on a build generated by Vite.

My workaround for that is to do npx source-map-explorer ./dist/assets/*.js --no-border-checks.

The --no-border-checks lets me analyze the bundle again, but superstruct will appear as a black box (for me it doesn't matter).

The functionality of superstruct itself has NOT been blocked by the warnings whatsoever, I can just ignore them.