Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function browserConfig(test = false) {
const baseConfig = {
input: input,
output: {
file: "browser/core-auth.js",
format: "umd",
name: "Azure.Core.Auth",
sourcemap: true
},
preserveSymlinks: false,
plugins: [
sourcemaps(),
replace({
delimiters: ["", ""],
values: {
// replace dynamic checks with if (false) since this is for
// browser only. Rollup's dead code elimination will remove
// any code guarded by if (isNode) { ... }
"if (isNode)": "if (false)"
}
}),
nodeResolve({
mainFields: ['module', 'browser'],
preferBuiltins: false
}),
cjs({
namedExports: { events: ["EventEmitter"] }
}),
viz({ filename: "browser/browser-stats.html", sourcemap: false })
__BUNDLER__: isBundlerESMBuild,
// support compile in browser?
__RUNTIME_COMPILE__: isRuntimeCompileBuild,
// support options?
// the lean build drops options related code with buildOptions.lean: true
__FEATURE_OPTIONS__: !packageOptions.lean && !process.env.LEAN,
__FEATURE_SUSPENSE__: true
}
// allow inline overrides like
//__RUNTIME_COMPILE__=true yarn build runtime-core
Object.keys(replacements).forEach(key => {
if (key in process.env) {
replacements[key] = process.env[key]
}
})
return replace(replacements)
}
export function nodeConfig(test = false) {
const externalNodeBuiltins = ["events", "util", "os"];
const baseConfig = {
input: input,
external: depNames.concat(externalNodeBuiltins),
output: { file: "dist/index.js", format: "cjs", sourcemap: true },
preserveSymlinks: false,
plugins: [
sourcemaps(),
replace({
delimiters: ["", ""],
values: {
// replace dynamic checks with if (true) since this is for node only.
// Allows rollup's dead code elimination to be more aggressive.
"if (isNode)": "if (true)"
}
}),
nodeResolve({ preferBuiltins: true }),
cjs(),
json()
]
};
baseConfig.external.push("crypto");
if (test) {
file: "browser/azure-keyvault-certificates.js",
banner: banner,
format: "umd",
name: "azurekeyvaultcertificates",
globals: {
"@azure/core-http": "Azure.Core.HTTP",
"@azure/core-arm": "Azure.Core.ARM",
"@azure/keyvault-keys": "Azure.KeyVault.Keys",
"@azure/keyvault-secrets": "Azure.KeyVault.Secrets"
},
sourcemap: true
},
preserveSymlinks: false,
plugins: [
sourcemaps(),
replace({
delimiters: ["", ""],
values: {
// replace dynamic checks with if (false) since this is for
// browser only. Rollup's dead code elimination will remove
// any code guarded by if (isNode) { ... }
"if (isNode)": ";isNode; if (false)"
}
}),
// os is not used by the browser bundle, so just shim it
shim({
dotenv: `export function config() { }`,
os: `
export const type = 1;
export const release = 1;
`
}),
export function browserConfig(test = false) {
const baseConfig = {
input: "dist-esm/src/index.browser.js",
output: {
file: "browser/azure-storage-file-datalake.js",
banner: banner,
format: "umd",
name: "azdatalake",
sourcemap: true
},
preserveSymlinks: false,
plugins: [
sourcemaps(),
replace({
delimiters: ["", ""],
values: {
// replace dynamic checks with if (false) since this is for
// browser only. Rollup's dead code elimination will remove
// any code guarded by if (isNode) { ... }
"if (isNode)": "if (false)"
}
}),
// fs and os are not used by the browser bundle, so just shim it
// dotenv doesn't work in the browser, so replace it with a no-op function
shim({
dotenv: `export function config() { }`,
fs: `
export function stat() { }
export function createReadStream() { }
export function createWriteStream() { }
},
check: opts.transpileOnly === false,
}),
babelPluginTsdx({
exclude: 'node_modules/**',
extensions: [...DEFAULT_EXTENSIONS, 'ts', 'tsx'],
passPerPreset: true,
custom: {
targets: opts.target === 'node' ? { node: '8' } : undefined,
extractErrors: opts.extractErrors,
format: opts.format,
// defines: opts.defines,
},
}),
opts.env !== undefined &&
replace({
'process.env.NODE_ENV': JSON.stringify(opts.env),
}),
sourceMaps(),
// sizeSnapshot({
// printInfo: false,
// }),
shouldMinify &&
terser({
sourcemap: true,
output: { comments: false },
compress: {
keep_infinity: true,
pure_getters: true,
passes: 10,
},
ecma: 5,
"os",
"stream",
"util"
];
const baseConfig = {
input: "dist-esm/src/index.js",
external: depNames.concat(externalNodeBuiltins),
output: {
file: "dist/index.js",
format: "cjs",
sourcemap: true
},
preserveSymlinks: false,
plugins: [
sourcemaps(),
replace({
delimiters: ["", ""],
values: {
// replace dynamic checks with if (true) since this is for node only.
// Allows rollup's dead code elimination to be more aggressive.
"if (isNode)": "if (true)"
}
}),
nodeResolve({ preferBuiltins: true }),
cjs({
namedExports: {
events: ["EventEmitter"],
assert: [
"ok",
"deepEqual",
"equal",
"fail",
export function browserConfig(test = false) {
const baseConfig = {
input: input,
output: {
file: "browser/index.js",
format: "umd",
name: "Azure.AMQPCommon",
sourcemap: true
},
preserveSymlinks: false,
plugins: [
sourcemaps(),
replace({
delimiters: ["", ""],
values: {
// replace dynamic checks with if (false) since this is for
// browser only. Rollup's dead code elimination will remove
// any code guarded by if (isNode) { ... }
"if (isNode)": "if (false)"
}
}),
// fs, net, and tls are used by rhea and need to be shimmed
// TODO: get these into rhea's pkg.browser field
// dotenv doesn't work in the browser, so replace it with a no-op function
shim({
fs: `export default {}`,
net: `export default {}`,
tls: `export default {}`,
export function browserConfig(test = false) {
const baseConfig = {
input: input,
external: ["ms-rest-js"],
output: {
file: "browser/logger.js",
format: "umd",
name: "Azure.Logger",
sourcemap: true
},
preserveSymlinks: false,
plugins: [
sourcemaps(),
replace(
// ms-rest-js is externalized so users must include it prior to using this bundle.
{
delimiters: ["", ""],
values: {
// replace dynamic checks with if (false) since this is for
// browser only. Rollup's dead code elimination will remove
// any code guarded by if (isNode) { ... }
"if (isNode)": "if (false)"
}
}
),
nodeResolve({
mainFields: ["module", "browser"],
preferBuiltins: false
}),
cjs({
const input = "./src/index.ts";
const globals = { react: "React" };
const external = Object.keys(globals);
const typescriptPlugin = typescript({
rollupCommonJSResolveHack: true,
clean: true,
verbosity: 2
});
const aliasPlugin = alias({
resolve: ["*.ts", "*.tsx"],
entries: {
components: path.resolve("./src/components")
}
});
const replaceProduction = replace({
"process.env.NODE_ENV": JSON.stringify("production")
});
export default [
{
input,
output: {
file: "lib/index.umd.js",
format: "umd",
name,
globals,
sourcemap: true
},
external,
plugins: [nodeResolve(), typescriptPlugin]
},