Skip to content

Commit

Permalink
Add basePath configuration to shared script config, inhibit empty war…
Browse files Browse the repository at this point in the history
…nings from node-resolve
  • Loading branch information
witemple-msft committed Jan 21, 2022
1 parent 8d18789 commit 818cf06
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
9 changes: 7 additions & 2 deletions common/tools/dev-tool/src/commands/run/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ export default leafCommand(commandInfo, async (options) => {
return false;
}

const basePath = path
.relative(process.cwd(), path.dirname(path.parse(info.packageJson.module).dir))
.split(path.sep)
.join("/");

if (options.production) {
const baseConfig: rollup.RollupOptions = {
// Use the package's module field if it has one
Expand Down Expand Up @@ -97,8 +102,8 @@ export default leafCommand(commandInfo, async (options) => {

const browserTestConfig = {
input: {
include: ["dist-esm/test/**/*.spec.js"],
exclude: ["dist-esm/test/**/node/**"],
include: [[basePath, "test", "**", "*.spec.js"].join("/")],
exclude: [[basePath, "test", "**", "node", "**"].join("/")],
},
preserveSymlinks: false,
plugins: [
Expand Down
18 changes: 18 additions & 0 deletions common/tools/dev-tool/src/config/rollup.base.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ function ignoreOpenTelemetryThisIsUndefined(warning: RollupWarning): boolean {
);
}

/**
* v1.0.0 of @azure/core-asynciterator-polyfill does not provide a source map.
*
* This was a bug, and this function works around that bug.
*/
function ignoreAsyncIteratorPolyfillSourceMaps(warning: RollupWarning): boolean {
return (
warning.code === "PLUGIN_WARNING" &&
Expand All @@ -95,11 +100,24 @@ function ignoreAsyncIteratorPolyfillSourceMaps(warning: RollupWarning): boolean
);
}

/**
* We ignore these warnings because some packages explicitly browser-map node builtins to `false`. Rollup will then
* complain that node-resolve's empty module does not export symbols from them, but as long as the package doesn't
* actually use those symbols at runtime in the browser tests, it should be fine.
*/
function ignoreMissingExportsFromEmpty(warning: RollupWarning): boolean {
return (
// I absolutely cannot explain why, but node-resolve's internal module ID for empty.js begins with a null byte.
warning.code === "MISSING_EXPORT" && warning.exporter?.trim() === "\0node-resolve:empty.js"
);
}

const warningInhibitors: Array<(warning: RollupWarning) => boolean> = [
ignoreChaiCircularDependency,
ignoreNiseSinonEval,
ignoreOpenTelemetryThisIsUndefined,
ignoreAsyncIteratorPolyfillSourceMaps,
ignoreMissingExportsFromEmpty,
];

/**
Expand Down

0 comments on commit 818cf06

Please sign in to comment.