-
-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: source maps to work correctly #51
Changes from all commits
28b6c1d
98e5256
2ed3438
a23245b
8b76b1a
03f293c
4a9e515
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,36 @@ | ||
import path from 'path'; | ||
import { createFsFromVolume, Volume } from 'memfs'; | ||
import { createFsRequire } from 'fs-require'; | ||
import sourceMapSupport from 'source-map-support'; | ||
import sourceMapSupport from '@cspotcode/source-map-support'; | ||
|
||
export const mfs = createFsFromVolume(new Volume()); | ||
|
||
// @ts-expect-error To support Webpack 4. No longer needed in WP5 | ||
mfs.join = path.join; | ||
|
||
let id: number; | ||
|
||
export const mRequire = (modulePath: string): any => { | ||
Check warning on line 13 in src/lib/memfs.ts GitHub Actions / Test (ubuntu-latest)
Check warning on line 13 in src/lib/memfs.ts GitHub Actions / Test (windows-latest)
Check warning on line 13 in src/lib/memfs.ts GitHub Actions / Test (ubuntu-latest)
|
||
const require = createFsRequire(mfs, { | ||
fs: true, | ||
}); | ||
|
||
id = require.id; | ||
|
||
return require(modulePath); | ||
}; | ||
|
||
sourceMapSupport.install({ | ||
environment: 'node', | ||
retrieveFile(filePath: string) { | ||
const fsRequirePrefix = `fs-require://${id}/`; | ||
|
||
if (filePath.startsWith(fsRequirePrefix)) { | ||
filePath = filePath.slice(fsRequirePrefix.length - 1); | ||
} | ||
|
||
if (mfs.existsSync(filePath)) { | ||
return mfs.readFileSync(filePath).toString(); | ||
} | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The tests seem to pass when removing this entire There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice catch :) |
||
}); | ||
|
||
export const mRequire = (modulePath: string): any => ( | ||
createFsRequire(mfs, { | ||
fs: true, | ||
})(modulePath) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not clear to me how this fork is different from the originalsource-map-support
so I'm going to revert this.NVM just saw the issue you linked!