-
Notifications
You must be signed in to change notification settings - Fork 8
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 sourcemap support #5
Conversation
billowz
commented
Mar 4, 2019
•
edited
edited
- Upgrade rollup to 1.0.0
- Added mapContent option
- Added sourcemap test case
- Fix source path in the sourcemap
Codecov Report
@@ Coverage Diff @@
## master #5 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 4 4
Lines 33 24 -9
=====================================
- Hits 33 24 -9
Continue to review full report at Codecov.
|
@Tao-Zeng , I think it's better to put the and good catch with "rm -rf" 👍 ...I forgot Windows exists |
@aMarCruz Rollup1.x does not generate source content when the plugin's sourcemap does not contain source content my test caseindex.ts //#if _DEBUG
export const a = 1
/*#else
export const a = 1
//#endif */ rollup config (rollup v1.3.2) export default {
input: 'src/index.ts',
output: {
name: 'test',
format: 'umd',
file: 'bundle.js',
sourcemap: true,
amd: {id: 'test'}
},
plugins: [
nodeResolve({ jsnext: true, extensions: ['.ts'] }),
commonjs(),
babel({extensions: ['.ts'] }),
jscc({ values: { _DEBUG: true } })
]
} bundle.js.map {"version":3,"file":"bundle.js","sources":["./src/src/index.ts"],"sourcesContent":[null],"names":["a"],"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;AAeA,MAAaA,CAAC,GAAG,CAAV;;;;"}
|
@aMarCruz The mapContent option is a better idea to work with the sourceupExcludeSources option of the rollup |
@Tao-Zeng I will check it asap. Thanks. |
9f3d183
to
9cba7b9
Compare
@aMarCruz I have rewritten the sourcemap fix code
The source path is incorrect for the following reasons: The source path in the sourcemap returned by jscc is the path relative to process.pwd(), rollup will resolve source path through the file's directory absolute path and the source path in the returned source map by the plugin const sources = originalSourcemap.sources;
const sourcesContent = originalSourcemap.sourcesContent || [];
if (sources == null || (sources.length <= 1 && sources[0] == null)) {
source = new Source(module.id, sourcesContent[0]);
sourcemapChain = [originalSourcemap as RawSourceMap].concat(sourcemapChain);
} else {
// TODO indiscriminately treating IDs and sources as normal paths is probably bad.
const directory = dirname(module.id) || '.';
const sourceRoot = originalSourcemap.sourceRoot || '.';
// parse the source path in sourcemap
const baseSources = sources.map(
(source, i) => new Source(resolve(directory, sourceRoot, source), sourcesContent[i])
);
source = new Link(originalSourcemap as any, baseSources) as any;
} See the rollup source: https://github.com/rollup/rollup/blob/v1.15.6/src/utils/collapseSourcemaps.ts#L196 I hope that you can check and merge the RP, Thanks. |
What is the status on this please? |
@atompkins , merged, I will publish a new version this week. |