Skip to content

Rename export files and folders #223

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

Merged
merged 2 commits into from
Jan 27, 2023
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
26 changes: 18 additions & 8 deletions config/rollup/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,29 @@ const plugins = [
function createBundleConfiguration(filename, format) {
const lowercaseFormat = format.toLowerCase();

if (![packageJSON.module, packageJSON.browser].includes(filename)) {
if (
![packageJSON.module, packageJSON.main, packageJSON.browser].includes(
filename
)
) {
throw new Error(`Invalid filename provided. Received: ${filename}`);
}

if (!["esm", "cjs"].includes(lowercaseFormat)) {
throw new Error(`Unrecognised output format provided. Received: ${format}`);
}

if (lowercaseFormat === "cjs" && filename !== packageJSON.browser) {
if (lowercaseFormat === "cjs" && filename !== packageJSON.main) {
throw new Error("A CJS bundle can only be created for the main bundle.");
}

if (lowercaseFormat === "esm" && filename !== packageJSON.module) {
throw new Error("An ESM bundle can only be created for the module bundle.");
if (
lowercaseFormat === "esm" &&
![packageJSON.module, packageJSON.browser].includes(filename)
) {
throw new Error(
"An ES module bundle can only be created for the module or browser bundle."
);
}

return {
Expand All @@ -73,7 +82,8 @@ function createBundleConfiguration(filename, format) {
};
}

const ESM = createBundleConfiguration(packageJSON.module, "esm");
const CJS = createBundleConfiguration(packageJSON.browser, "cjs");

export default [ESM, CJS];
export default [
createBundleConfiguration(packageJSON.module, "esm"),
createBundleConfiguration(packageJSON.browser, "esm"),
createBundleConfiguration(packageJSON.main, "cjs")
];
2 changes: 1 addition & 1 deletion config/typescript/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"outDir": "../../dist/components",
"outDir": "../../dist/react-p5-wrapper",
"declaration": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
Expand Down
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{
"name": "react-p5-wrapper",
"version": "4.0.1",
"version": "4.1.0",
"description": "A wrapper component that allows you to utilise P5 sketches within React apps.",
"homepage": "https://github.com/P5-wrapper/react",
"license": "MIT",
"type": "module",
"browser": "dist/components/index.js",
"module": "dist/components/index.esm.js",
"types": "dist/components/index.d.ts",
"main": "dist/react-p5-wrapper/index.js",
"browser": "dist/react-p5-wrapper/index.browser.js",
"module": "dist/react-p5-wrapper/index.module.js",
"types": "dist/react-p5-wrapper/index.d.ts",
"files": [
"dist/components/*"
"dist/react-p5-wrapper/*"
],
"scripts": {
"aui": "pnpm audit && pnpm update && pnpm install",
Expand Down