Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import {concat, link, generate} from '@parcel/scope-hoisting';
import SourceMap from '@parcel/source-map';
import {
countLines,
PromiseQueue,
relativeBundlePath,
replaceBundleReferences,
} from '@parcel/utils';
import path from 'path';
const PRELUDE = fs
.readFileSync(path.join(__dirname, 'prelude.js'), 'utf8')
.trim()
.replace(/;$/, '');
export default new Packager({
async package({
bundle,
bundleGraph,
getInlineBundleContents,
getSourceMapReference,
options,
}) {
function replaceReferences({contents, map}) {
return replaceBundleReferences({
bundle,
bundleGraph,
contents,
getInlineReplacement: (dependency, inlineType, content) => ({
from: `"${dependency.id}"`,
to: inlineType === 'string' ? JSON.stringify(content) : content,
}),