Skip to content

Commit

Permalink
fix(esm-shim): bump dependencies (#1499)
Browse files Browse the repository at this point in the history
* fix(esm-shim): bump dependencies

* fix(esm-shim): access sourcesContent instead of sources property
  • Loading branch information
tada5hi committed May 17, 2023
1 parent 5bee8cd commit 0dc90ec
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/esm-shim/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
}
},
"dependencies": {
"magic-string": "^0.27.0"
"magic-string": "^0.30.0"
},
"devDependencies": {
"rollup": "^3.0.0-7",
Expand Down
19 changes: 18 additions & 1 deletion packages/esm-shim/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,25 @@ export function provideCJSSyntax(code: string): Output | null {
const s = new MagicString(code);
s.appendRight(indexToAppend, ESMShim);

const sourceMap = s.generateMap({
includeContent: true
});
let sourcesContent: string[] | undefined;
if (Array.isArray(sourceMap.sourcesContent)) {
sourcesContent = [];
for (let i = 0; i < sourceMap.sourcesContent.length; i++) {
const content = sourceMap.sourcesContent[i];
if (typeof content === 'string') {
sourcesContent.push(content);
}
}
}

return {
code: s.toString(),
map: s.generateMap()
map: {
...sourceMap,
sourcesContent
}
};
}
11 changes: 9 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0dc90ec

Please sign in to comment.