Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"import-from", // depends on pure Node.js module semantics
"resolve-from", // depends on pure Node.js module semantics
"resolve-pkg", // depends on pure Node.js module semantics
"loader-runner",
"use", // unresolvable assets (snapdragon)
"webpack", // bloats bundle to 2.5x size
"webpack-dev-middleware", // bloats bundle to 2.5x size
"express", // express/lib/view creates an expression require
"errorhandler", // non-resolvable static assets
"require-from-string", // fails unpredictably
"meow", // installed in cli anyway
"chalk", // installed in cli anyway,
"@patternplate/compiler" // needs relative access to itself
];
const EXTERNALS = builtinModules.concat(EXCLUDED);
module.exports = {
entry: {
build: "./src/build/index.js",
create: "./src/create/index.js",
start: "./src/start/index.js"
},
target: "node",
externals: [
(context, request, callback) => {
if (request.charAt(0) === ".") {
return callback();
}
if (EXTERNALS.indexOf(request) > -1){
return callback(null, 'commonjs ' + request);
return Promise.all(bundle.bundleTypes.map(bundleType => {
const entry = 'src/index.ts';
return rollup({
input: path.resolve(bundle.path, entry),
external: builtinModules.concat(bundleType === NODE ? Object.keys(pkg.dependencies) : []),
plugins: getRollupPlugins(bundleType),
}).then(output => {
const formats = getOutputFormatsFromBundleType(bundleType);
return Promise.all(formats.map(format => {
const file = getOutpupFilenameFormBundleType(bundle.filename, format, bundleType);
return output.write({
format: format,
name: bundle.global,
file: path.resolve(bundle.path, file)
}).then(() => {
console.log(' \u2713' + ' wrote ' +
path.basename(path.resolve(bundle.path)) + '/' + file);
})
}))
});
}));
const createNodeJsEntry = (cryptoType, format) => {
const foundationModuleName = '@virgilsecurity/core-foundation';
const foundationEntryPoint = path.join(foundationModuleName, getCryptoEntryPointName(TARGET.NODE, cryptoType, format));
const pythiaModuleName = '@virgilsecurity/pythia-crypto';
const pythiaEntryPoint = path.join(pythiaModuleName, 'dist', getCryptoEntryPointName(TARGET.NODE, cryptoType, format));
const external = builtinModules.concat(Object.keys(packageJson.dependencies)).concat([foundationEntryPoint, pythiaEntryPoint]);
const outputFileName = getCryptoEntryPointName(TARGET.NODE, cryptoType, format);
const tsconfigOverride = format === FORMAT.ES ? { compilerOptions: { target: 'es2015' } } : {};
return {
input: path.join(sourceDir, 'index.node.ts'),
output: {
format,
file: path.join(outputDir, outputFileName)
},
external,
plugins: [
replace({
replaces: {
'process.env.PRODUCT_NAME': JSON.stringify(PRODUCT_NAME),
'process.env.PRODUCT_VERSION': JSON.stringify(packageJson.version),
}
const createEntry = (format, isBrowser) => {
let filename = 'virgil-sdk';
if (isBrowser) {
filename += '.browser';
}
filename += `.${format}.js`;
let tsconfigOverride = format === FORMAT.ES ? { compilerOptions: { target: 'es2015' } } : {};
return {
external: builtinModules.concat(isBrowser ? [] : Object.keys(packageJson.dependencies)),
input,
output: {
format,
file: path.join(outputPath, filename),
name: 'Virgil',
},
plugins: [
isBrowser && nodeResolve({
browser: true,
extensions: ['.ts', '.js']
}),
isBrowser && commonjs(),
replace({
'process.browser': JSON.stringify(isBrowser),
'process.env.VERSION': JSON.stringify(packageJson.version),
}),
const createEntry = (cryptoType, format) => {
const foundationModuleName = '@virgilsecurity/core-foundation';
const foundationEntryPoint = path.join(
foundationModuleName,
getCryptoEntryPointName(cryptoType, format),
);
const pythiaModuleName = '@virgilsecurity/pythia-crypto';
const pythiaEntryPoint = path.join(
pythiaModuleName,
'dist',
getCryptoEntryPointName(cryptoType, format),
);
const external = builtinModules
.concat(Object.keys(packageJson.dependencies))
.concat([foundationEntryPoint, pythiaEntryPoint]);
const outputFileName = getCryptoEntryPointName(cryptoType, format);
return {
external,
input: path.join(sourcePath, 'index.ts'),
output: {
format,
file: path.join(outputPath, outputFileName),
},
plugins: [
nodeResolve(),
commonjs(),
replace({
replaces: {
const createNodeJsEntry = (cryptoType, format) => ({
input: path.join(sourceDir, 'index.ts'),
output: {
format,
file: path.join(outputDir, getOutputFilename(TARGET.NODE, cryptoType, format)),
},
external: builtinModules.concat(Object.keys(packageJson.dependencies)),
plugins: [
replace({
patterns: [
{
match: /(initPythia|types)\.ts$/,
test: '@virgilsecurity/core-pythia',
replace: path.join(
'@virgilsecurity',
'core-pythia',
getCryptoEntryPointName(TARGET.NODE, cryptoType),
),
},
],
}),
nodeResolve({ extensions: ['.js', '.ts'] }),
commonjs(),
const createNodeJsEntry = (cryptoType, format) => {
const foundationEntryPoint = path.join(
'@virgilsecurity',
'core-foundation',
getCryptoEntryPointName(TARGET.NODE, cryptoType, format),
);
return {
input: path.join(sourceDir, 'index.ts'),
output: {
format,
file: path.join(outputDir, getOutputFilename(TARGET.NODE, cryptoType, format)),
},
external: builtinModules
.concat(Object.keys(packageJson.dependencies))
.concat([foundationEntryPoint]),
plugins: [
replace({
patterns: [
{
match: /foundationModules\.ts$/,
test: '@virgilsecurity/core-foundation',
replace: foundationEntryPoint,
},
],
}),
nodeResolve({ extensions: ['.js', '.ts'] }),
commonjs(),
typescript({
exclude: ['**/*.test.ts'],