Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function compile (name, output) { // eslint-disable-line no-unused-vars
console.log(name, '→', output)
mkdirp.sync(path.dirname(path.join(__dirname, output)))
var source = fs.readFileSync(require.resolve(name), 'utf8')
var result = buble.transform(source, {
transforms: {
dangerousForOf: true
}
})
fs.writeFileSync(path.join(__dirname, output), HEADER + result.code, 'utf8')
}
function compile (name, output) { // eslint-disable-line no-unused-vars
console.log(name, '→', output)
mkdirp.sync(path.dirname(path.join(__dirname, output)))
var source = fs.readFileSync(require.resolve(name), 'utf8')
var result = buble.transform(source, {
transforms: {
dangerousForOf: true
}
})
fs.writeFileSync(path.join(__dirname, output), HEADER + result.code, 'utf8')
}
function compile (name, output) { // eslint-disable-line no-unused-vars
console.log(name, '→', output)
mkdirp.sync(path.dirname(path.join(__dirname, output)))
var source = fs.readFileSync(require.resolve(name), 'utf8')
var result = buble.transform(source, {
transforms: {
dangerousForOf: true
}
})
fs.writeFileSync(path.join(__dirname, output), HEADER + result.code, 'utf8')
}
.add('acorn + buble', () => {
buble(code, bubleOptions).code
})
// add listeners
transform: function ( source, id ) {
return buble.transform( source, {
transforms: { modules: false }
});
}
},
transform(source, id) {
return buble.transform(source, {
transforms: { modules: false }
});
}
},
.then(() => {
if (unintendedError) throw unintendedError;
if (config.error || config.generateError) return;
if (config.buble) {
for (const chunk of result) {
if (chunk.code) {
chunk.code = buble.transform(chunk.code, {
transforms: { modules: false }
}).code;
}
}
}
const codeMap = result.reduce((codeMap, chunk) => {
codeMap[chunk.fileName] = chunk.code;
return codeMap;
}, {});
if (config.code) {
config.code(result.length === 1 ? result[0].code : codeMap);
}
const entryId = result.length === 1 ? result[0].fileName : 'main.js';
if (!codeMap.hasOwnProperty(entryId)) {
const moduleToBrowser = code =>
umdBoiler.replace(
'{{CODE}}',
code
.replace(/export\s+(const|let|var)\s+([^\s]+)/gi, '$1 $2 = exports.$2')
.replace(/export\s+\{([^}]+)\}/, (_, names) =>
names
.split(',')
.map(name => `exports.${name} = ${name}`)
.join('\n')
)
.replace(/export\s+default\s+([^\s]+)/gi, 'exports = assign($1, exports)')
.replace(/^/gm, ' ')
)
const bubleOut = buble.transform(moduleToBrowser(input), {
modules: false,
transforms: { dangerousForOf: true }
})
const bubleTerserOut = Terser.minify(
{ [es5SrcName]: bubleOut.code },
{ ecma: 5, sourceMap: { filename: es5OutName, url: es5OutName + '.map' } }
)
const reportDiff = (path, newCode) => {
if (!fss.existsSync(path)) return
const beforeSize = fss.statSync(path).size
const beforeGzip = zlib.gzipSync(fss.readFileSync(path)).byteLength
const afterSize = newCode.length
const afterGzip = zlib.gzipSync(Buffer.from(newCode, 'utf-8')).byteLength
console.log(
[
function compile (name, output, fix) {
console.log(name, '→', output)
mkdirp.sync(path.dirname(path.join(__dirname, output)))
var source = fs.readFileSync(require.resolve(name), 'utf8')
if (fix) source = fix(source)
var result = buble.transform(source, {
transforms: {
dangerousForOf: true
}
})
fs.writeFileSync(path.join(__dirname, output), HEADER + result.code, 'utf8')
}
function compile (name, output, fix) {
console.log(name, '→', output)
mkdirp.sync(path.dirname(path.join(__dirname, output)))
var source = fs.readFileSync(require.resolve(name), 'utf8')
if (fix) source = fix(source)
var result = buble.transform(source, {
transforms: {
dangerousForOf: true
}
})
fs.writeFileSync(path.join(__dirname, output), HEADER + result.code, 'utf8')
}