-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I'm making a cloud playground website that can import any library registered in the NPM registry with `esm.sh`. By the way, as `esm.sh` has been published for `deno`, it is not possible to import `NodeJS` built-in libraries. In such reason, this PR removes every direct import statements to the NodeJS built-in libraries, and performed indirect import through `import2` library, so that bundler cannot merge them.
- Loading branch information
Showing
5 changed files
with
25 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,24 @@ | ||
import { NodeModule } from "../../../../utils/internal/NodeModule"; | ||
|
||
/** | ||
* @hidden | ||
*/ | ||
export class ProcessChannel { | ||
public static postMessage(message: any): void { | ||
(global.process as Required<NodeJS.Process>).send(message); | ||
NodeModule.process().send!(message); | ||
} | ||
|
||
public static close(): void { | ||
global.process.exit(); | ||
NodeModule.process().exit(); | ||
} | ||
|
||
public static set onmessage(listener: (event: MessageEvent) => void) { | ||
global.process.on("message", (msg) => { | ||
NodeModule.process().on("message", (msg) => { | ||
listener({ data: msg } as MessageEvent); | ||
}); | ||
} | ||
|
||
public static is_worker_server(): boolean { | ||
return !!global.process.send; | ||
return !!NodeModule.process().send; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters