Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide circular dependency warnings #59

Merged
merged 3 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/nice-hats-sing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@lookit/lookit-initjspsych": patch
"@lookit/surveys": patch
"@lookit/record": patch
"@lookit/style": patch
"@lookit/data": patch
---

Update rollup config to hide known circular warnings
44 changes: 44 additions & 0 deletions rollup.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,51 @@
/* eslint-disable func-style */

import { makeRollupConfig as jsPsychMakeRollupConfig } from "@jspsych/config/rollup";
import { iifeNameData } from "./packages/data/rollup.config.mjs";

/**
* Create rollup config for any package.
*
* @param iifeName - IIFE Name for this package
* @returns Rollup config
*/
export function makeRollupConfig(iifeName) {
const dataPackageName = "@lookit/data";

const knownCircularDeps = [
"@smithy/util-stream/dist-es/blob/Uint8ArrayBlobAdapter.js",
"@smithy/util-endpoints/dist-es/utils/callFunction.js",
"@smithy/util-endpoints/dist-es/utils/getEndpointProperties.js",
"@smithy/util-endpoints/dist-es/utils/evaluateRules.js",
"@aws-crypto/crc32/build/module/index.js",
"@aws-crypto/crc32c/build/module/index.js",
];

/**
* Change warnings into errors. This will help us catch build concerns before
* they are in production. Also, hide known circular dependency warnings. This
* is copied from Rollup's documentation:
* https://rollupjs.org/configuration-options/#onlog
*
* @param level - Message level
* @param log - Log object containing location, frame, and message.
* @param handler - Function called to record log.
*/
const onLog = (level, log, handler) => {
// Don't log known circular dependencies with the data package.
if (log.code === "CIRCULAR_DEPENDENCY" && iifeName === "chsData") {
if (knownCircularDeps.some((value) => log.message.includes(value))) {
return;
}
}

if (level === "warn") {
handler("error", log);
} else {
handler(level, log);
}
};

return jsPsychMakeRollupConfig(iifeName).map((config) => {
return {
...config,
Expand All @@ -18,6 +61,7 @@ export function makeRollupConfig(iifeName) {
},
};
}),
onLog,
};
});
}