|
1 | | -// Copyright (c) Microsoft Corporation. All rights reserved. |
2 | | -// Licensed under the MIT License. |
| 1 | +import cjs from "@rollup/plugin-commonjs"; |
| 2 | +import inject from "@rollup/plugin-inject"; |
| 3 | +import json from "@rollup/plugin-json"; |
| 4 | +import multiEntry from "@rollup/plugin-multi-entry"; |
| 5 | +import nodeResolve from "@rollup/plugin-node-resolve"; |
| 6 | +import replace from "@rollup/plugin-replace"; |
| 7 | +import shim from "rollup-plugin-shim"; |
| 8 | +import sourcemaps from "rollup-plugin-sourcemaps"; |
| 9 | +import { makeConfig, makeBrowserTestConfig } from "@azure/dev-tool/shared-config/rollup"; |
3 | 10 |
|
4 | | -import * as base from "./rollup.base.config"; |
| 11 | +const inputs = makeConfig(require("./package.json")); |
5 | 12 |
|
6 | | -// Node tests are run via ts-node |
7 | | -export default [base.browserConfig(true)]; |
| 13 | +if (!process.env.ONLY_NODE) { |
| 14 | + // service-bus has many dependencies that we do not |
| 15 | + // want to bring into the shared rollup config, so |
| 16 | + // replace the original test config with a patched one |
| 17 | + inputs[1] = makeBrowserTestConfigPatch(); |
| 18 | +} |
| 19 | + |
| 20 | +function makeBrowserTestConfigPatch() { |
| 21 | + const config = { ...makeBrowserTestConfig(require("./package.json")) }; |
| 22 | + config.plugins = [ |
| 23 | + multiEntry({ exports: false }), |
| 24 | + sourcemaps(), |
| 25 | + replace({ |
| 26 | + delimiters: ["", ""], |
| 27 | + }), |
| 28 | + // fs, net, and tls are used by rhea and need to be shimmed |
| 29 | + shim({ |
| 30 | + os: `export default { }`, |
| 31 | + path: `export default { }`, |
| 32 | + }), |
| 33 | + nodeResolve({ |
| 34 | + mainFields: ["module", "browser"], |
| 35 | + preferBuiltins: false, |
| 36 | + }), |
| 37 | + cjs({ |
| 38 | + namedExports: { |
| 39 | + chai: ["should", "assert"], |
| 40 | + assert: ["equal", "deepEqual", "notEqual"], |
| 41 | + }, |
| 42 | + }), |
| 43 | + // rhea and rhea-promise use the Buffer global which requires |
| 44 | + // injection to shim properly |
| 45 | + inject({ |
| 46 | + modules: { |
| 47 | + Buffer: ["buffer", "Buffer"], |
| 48 | + process: "process", |
| 49 | + }, |
| 50 | + exclude: ["./**/package.json"], |
| 51 | + }), |
| 52 | + json(), |
| 53 | + ]; |
| 54 | + |
| 55 | + return config; |
| 56 | +} |
| 57 | + |
| 58 | +export default inputs; |
0 commit comments