From 704961755f41637bab84010e1ae0defc5a8b8649 Mon Sep 17 00:00:00 2001 From: CJ Green <44074998+okaycj@users.noreply.github.com> Date: Thu, 17 Oct 2024 10:25:56 -0400 Subject: [PATCH] Fix Rollupjs build issue --- .gitignore | 3 ++- package-lock.json | 4 +++- package.json | 2 ++ packages/data/rollup.config.mjs | 4 +--- packages/record/package.json | 2 +- packages/templates/tsconfig.json | 1 + rollup.mjs | 20 +++++++++++++------- 7 files changed, 23 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 2bf7ce66..007e4da5 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ coverage Procfile .env site -.DS_Store \ No newline at end of file +.DS_Store +packages/style/**/*.js \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 1fec2977..90f45c15 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,8 @@ "version": "1.0.0", "license": "ISC", "workspaces": [ + "packages/data", + "packages/templates", "packages/*" ], "dependencies": { @@ -20089,7 +20091,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", @@ -20106,6 +20107,7 @@ }, "peerDependencies": { "@lookit/data": "^0.0.3", + "@lookit/templates": "^0.0.0", "jspsych": "^8.0.2" } }, diff --git a/package.json b/package.json index 3eb58ea5..860936fb 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,8 @@ "author": "", "main": "index.js", "workspaces": [ + "packages/data", + "packages/templates", "packages/*" ], "scripts": { diff --git a/packages/data/rollup.config.mjs b/packages/data/rollup.config.mjs index a985b195..010f204b 100644 --- a/packages/data/rollup.config.mjs +++ b/packages/data/rollup.config.mjs @@ -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: [ diff --git a/packages/record/package.json b/packages/record/package.json index 8a715083..df3deee3 100644 --- a/packages/record/package.json +++ b/packages/record/package.json @@ -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", @@ -48,6 +47,7 @@ }, "peerDependencies": { "@lookit/data": "^0.0.3", + "@lookit/templates": "^0.0.0", "jspsych": "^8.0.2" } } diff --git a/packages/templates/tsconfig.json b/packages/templates/tsconfig.json index 5a9987dc..c0697c56 100644 --- a/packages/templates/tsconfig.json +++ b/packages/templates/tsconfig.json @@ -1,6 +1,7 @@ { "compilerOptions": { "baseUrl": ".", + "esModuleInterop": true, "strict": true }, "extends": "@jspsych/config/tsconfig.json", diff --git a/rollup.mjs b/rollup.mjs index 75df2211..760da72a 100644 --- a/rollup.mjs +++ b/rollup.mjs @@ -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. @@ -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", @@ -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; } @@ -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, }; }); }