Skip to content

Commit

Permalink
Update rollup config
Browse files Browse the repository at this point in the history
This commit will do two things.  First, this will only bundle iife configs. Second, it adds the data package as an external dependency.
  • Loading branch information
okaycj committed May 15, 2024
1 parent 2222cdd commit 4484a1e
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 17 deletions.
26 changes: 13 additions & 13 deletions packages/data/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { makeRollupConfig } from "@jspsych/config/rollup";
import { nodeResolve } from "@rollup/plugin-node-resolve";
import dotenv from "rollup-plugin-dotenv";
import { makeRollupConfig } from "../../rollup.mjs";

const config = makeRollupConfig("chsData");
export const iifeNameData = "chsData";

config.map((c) => {
c.plugins = [
nodeResolve({
browser: true,
preferBuiltins: false,
}),
dotenv(),
...c.plugins,
];
export default makeRollupConfig(iifeNameData).map((config) => {
return {
...config,
plugins: [
// Resolve node dependencies to be used in a browser.
nodeResolve({ browser: true, preferBuiltins: false }),
// Add support for .env files
dotenv(),
...config.plugins,
],
};
});

export default config;
4 changes: 2 additions & 2 deletions packages/lookit-initjspsych/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { makeRollupConfig } from "@jspsych/config/rollup";

import { makeRollupConfig } from "../../rollup.mjs";
// This package name needs to be unique
export default makeRollupConfig("chsInitJsPsych");
2 changes: 1 addition & 1 deletion packages/record/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { makeRollupConfig } from "@jspsych/config/rollup";
import { makeRollupConfig } from "../../rollup.mjs";
// This package name needs to be unique
export default makeRollupConfig("chsRecord");
2 changes: 1 addition & 1 deletion packages/surveys/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { makeRollupConfig } from "@jspsych/config/rollup";
import { makeRollupConfig } from "../../rollup.mjs";
// This package name needs to be unique
export default makeRollupConfig("chsSurvey");
25 changes: 25 additions & 0 deletions rollup.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { makeRollupConfig as jsPsychMakeRollupConfig } from "@jspsych/config/rollup";
import { iifeNameData } from "./packages/data/rollup.config.mjs";

export function makeRollupConfig(iifeName) {
return jsPsychMakeRollupConfig(iifeName).map((config) => {
return {
...config,
// Add data package as external dependency
external: [...config.external, "@lookit/data"],
output: config.output
// Only build iife bundles
.filter((output) => output.format === "iife")
.map((output) => {
return {
...output,
globals: {
...output.globals,
// Explicitly state data's iife name
"@lookit/data": iifeNameData,
},
};
}),
};
});
}

0 comments on commit 4484a1e

Please sign in to comment.