Skip to content

Commit

Permalink
Fix vega-lite integration
Browse files Browse the repository at this point in the history
  • Loading branch information
kachkaev committed May 9, 2021
1 parent 493b4e9 commit eebd2cf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
This changelog is for the fork, not the [original mume library](https://github.com/shd101wyy/mume/).

## Unreleased (patch)

- Fix vega-lite integration

## 0.32.0

- Upgrade vega to 5.20.2, vega-lite to 5.1.0, vega-embed to 6.17.0 and apache-arrow to 4.0.0
Expand Down
15 changes: 11 additions & 4 deletions src/utility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -535,13 +535,20 @@ export function allowUnsafe<T>(fn: () => T): T {
}

export const loadDependency = (dependencyPath: string) =>
allowUnsafe(() =>
require(path.resolve(
allowUnsafe(() => {
// Unsetting global.module prevents libraries like vega-lite from calling require(), which does not work
const prevModule = global.module;
global.module = undefined;

const result = require(path.resolve(
extensionDirectoryPath,
"dependencies",
dependencyPath,
)),
);
));

global.module = prevModule;
return result;
});

export const extractCommandFromBlockInfo = (info: BlockInfo) =>
info.attributes["cmd"] === true ? info.language : info.attributes["cmd"];
Expand Down

0 comments on commit eebd2cf

Please sign in to comment.