Skip to content

Instantly share code, notes, and snippets.

View zavr-1's full-sized avatar
🍁
Depack: Front-End Code and Node.JS Package Bundler With Google Closure Compiler.

zavr-1

🍁
Depack: Front-End Code and Node.JS Package Bundler With Google Closure Compiler.
View GitHub Profile
@zavr-1
zavr-1 / child_process.js
Last active December 4, 2018 12:45
externs/DEPACH$child_process is used to mock the child_process module.
/*
* Copyright 2012 The Closure Compiler Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@zavr-1
zavr-1 / wrapper.js
Last active December 4, 2018 13:37
// The possible output wrapper, which however does not
// allow to disable strict mode.
function() {
const DEPACK$child_process = require('child_process');
%output%
}(this)
@zavr-1
zavr-1 / error.js
Last active December 4, 2018 12:25
import { fork } from 'child_process'
const { stdout, stderr } = fork('.', [], {
stdio: 'pipe',
execArgv: [], // for when debugging
}).on('error', (error) => {
console.log(error)
})
stdout.pipe(process.stdout)
// The package 'child_process' source code
export default DEPACK$child_process
export const {
ChildProcess,
exec,
execFile,
execFileSync,
execSync,
fork,
spawn,
{"name":"child_process","main":"index.js","depack":"v8"}
@zavr-1
zavr-1 / tt.js
Last active December 5, 2018 06:10
// tt.js (compiled code in PRETTY_PRINT)
const DEPACK$child_process = require('child_process');
'use strict';
const {fork:a} = DEPACK$child_process;
const {stdout:b, stderr:c} = a(".", [], {stdio:"pipe", execArgv:[]}).on("error", (d) => {
console.log(d);
});
b.pipe(process.stdout);
c.pipe(process.stderr);
/**
* @constructor
*/
var Buffer = function() {}
Buffer.concat
var process
process.stdout
process.stderr
process.version
@zavr-1
zavr-1 / index.js
Last active December 5, 2018 06:09
// index.js
console.log('hello world')
console.warn(process.version)
hello world
v8.13.0
// internals: [ 'child_process' ]
const requires = internals.map((key) => {
return `const DEPACK$${key} = require('${key}');`
}).join('\n')
const data = `${requires}\n${stdout}`
/*
const DEPACK$child_process = require('child_process');
'use strict';
const {fork:a} = DEPACK$child_process;