Skip to content
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
13 changes: 12 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,18 @@
"name": "@stackone/hub",
"version": "0.3.0",
"description": "StackOne HUB",
"main": "index.js",
"main": "dist/index.js",
"module": "dist/index.esm.js",
"types": "dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.esm.js",
"require": "./dist/index.js"
},
"./webcomponent": "./dist/webcomponent.js"
},
"files": ["dist"],
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "rollup -c",
Expand Down
49 changes: 32 additions & 17 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,64 +9,79 @@ import external from "rollup-plugin-peer-deps-external";
import postcss from "rollup-plugin-postcss";

export default [
// React Component Bundle (external React)
// Main React Component Bundle
{
input: "src/index.ts",
output: [
{
file: "dist/react/StackOneHub.esm.js",
file: "dist/index.esm.js",
format: "esm",
},
{
file: "dist/react/StackOneHub.cjs.js",
file: "dist/index.js",
format: "cjs",
},
],
external: ["react", "react-dom", "react-hook-form"],

Copilot AI Aug 28, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The external dependencies array should be moved to a shared constant or configuration object to avoid duplication if other bundles need the same externals. This improves maintainability when dependencies change.

Copilot uses AI. Check for mistakes.
plugins: [
del({ targets: "dist/react/*" }),
external(),
resolve(),
del({ targets: "dist/*" }),

Copilot AI Aug 28, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a wildcard deletion dist/* in the first bundle configuration will clean the entire dist directory, potentially removing files that other bundles in the same build process might need. Consider using more specific targets or coordinating the cleanup across all bundle configurations.

Suggested change
del({ targets: "dist/*" }),
del({ targets: "dist/*", runOnce: true }),

Copilot uses AI. Check for mistakes.
resolve({
preferBuiltins: false,
}),
commonjs(),
typescript({ tsconfig: "./tsconfig.json" }),
postcss(),
terser(),
typescript({
tsconfig: "./tsconfig.json",
declaration: false,
}),
postcss({
extract: false,
inject: true,
}),
replace({
preventAssignment: true,
"process.env.NODE_ENV": JSON.stringify("production"),
}),
terser(),
],
},

// Web Component Bundle (bundled React)
{
input: "src/WebComponentWrapper.tsx",
output: {
file: "dist/webcomponent/StackOneHub.web.js",
file: "dist/webcomponent.js",
format: "iife",
name: "StackOneHubWebComponent",
sourcemap: true,
},
plugins: [
del({ targets: "dist/webcomponent/*" }), // Clean the dist folder before each build
resolve(),
resolve({
preferBuiltins: false,
}),
commonjs(),
typescript({ tsconfig: "./tsconfig.json" }),
postcss(),
terser(),
typescript({
tsconfig: "./tsconfig.json",
declaration: false,
}),
postcss({
extract: false,
inject: true,
}),
replace({
preventAssignment: true,
"process.env.NODE_ENV": JSON.stringify("production"),
}),
terser(),
],
},

// Declaration file bundle
// TypeScript declarations
{
input: "src/index.ts",
output: {
file: "dist/index.d.ts",
format: "es",
},
plugins: [del({ targets: "dist/index.d.ts" }), dts()],
plugins: [dts()],
},
];