Skip to content

Commit

Permalink
Fix Rollupjs build issue
Browse files Browse the repository at this point in the history
  • Loading branch information
okaycj committed Oct 17, 2024
1 parent 20bca3a commit 7049617
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 13 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ coverage
Procfile
.env
site
.DS_Store
.DS_Store
packages/style/**/*.js
4 changes: 3 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
"author": "",
"main": "index.js",
"workspaces": [
"packages/data",
"packages/templates",
"packages/*"
],
"scripts": {
Expand Down
4 changes: 1 addition & 3 deletions packages/data/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import { nodeResolve } from "@rollup/plugin-node-resolve";
import dotenv from "rollup-plugin-dotenv";
import { makeRollupConfig } from "../../rollup.mjs";

export const iifeNameData = "chsData";

export default makeRollupConfig(iifeNameData).map((config) => {
export default makeRollupConfig("chsData").map((config) => {
return {
...config,
plugins: [
Expand Down
2 changes: 1 addition & 1 deletion packages/record/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"devDependencies": {
"@jspsych/config": "^2.0.0",
"@jspsych/test-utils": "^1.2.0",
"@lookit/templates": "^0.0.0",
"@rollup/plugin-image": "^3.0.3",
"@rollup/plugin-replace": "^6.0.1",
"@types/audioworklet": "^0.0.60",
Expand All @@ -48,6 +47,7 @@
},
"peerDependencies": {
"@lookit/data": "^0.0.3",
"@lookit/templates": "^0.0.0",
"jspsych": "^8.0.2"
}
}
1 change: 1 addition & 0 deletions packages/templates/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"compilerOptions": {
"baseUrl": ".",
"esModuleInterop": true,
"strict": true
},
"extends": "@jspsych/config/tsconfig.json",
Expand Down
20 changes: 13 additions & 7 deletions rollup.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* 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.
Expand All @@ -10,8 +9,10 @@ import { iifeNameData } from "./packages/data/rollup.config.mjs";
* @returns Rollup config
*/
export function makeRollupConfig(iifeName) {
const dataPackageName = "@lookit/data";

const packages = {
data: { name: "@lookit/data", iife: "chsData" },
templates: { name: "@lookit/templates", iife: "chsTemplates" },
};
const knownCircularDeps = [
"@smithy/util-stream/dist-es/blob/Uint8ArrayBlobAdapter.js",
"@smithy/util-endpoints/dist-es/utils/callFunction.js",
Expand All @@ -33,7 +34,7 @@ export function makeRollupConfig(iifeName) {
*/
const onLog = (level, log, handler) => {
// Don't log known circular dependencies with the data package.
if (log.code === "CIRCULAR_DEPENDENCY" && iifeName === "chsData") {
if (log.code === "CIRCULAR_DEPENDENCY" && iifeName === packages.data.iife) {
if (knownCircularDeps.some((value) => log.message.includes(value))) {
return;
}
Expand All @@ -49,19 +50,24 @@ export function makeRollupConfig(iifeName) {
return jsPsychMakeRollupConfig(iifeName).map((config) => {
return {
...config,
onLog,
// Add data package as external dependency
external: [...config.external, dataPackageName],
external: [
...config.external,
packages.data.name,
packages.templates.name,
],
output: config.output.map((output) => {
return {
...output,
globals: {
...output.globals,
// Explicitly state data's iife name
[dataPackageName]: iifeNameData,
[packages.data.name]: packages.data.iife,
[packages.templates.name]: packages.templates.iife,
},
};
}),
onLog,
};
});
}

0 comments on commit 7049617

Please sign in to comment.