Skip to content
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

Optimise distributive for ES6 and CJS modules #45

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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#distributive files
/browser/*.*
/esm/*.*
*.js
*.mjs
*.map
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
node_modules
coverage
browser
esm
*.js
*.mjs
!rollup.config.js
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.6.5",
"description": "The library brings most of the familiar functional techniques (like functional composition) to asynchronous world with shining Promises",
"main": "index.js",
"module": "index.mjs",
"module": "esm/index.js",
"scripts": {
"test": "node -r esm scripts/unitTest.js",
"lint": "npx eslint '**/*.js'",
Expand Down
8 changes: 5 additions & 3 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ ${licenseText.replace(/^/gm, " * ")}
};

const getSourceFilesList = () => globby(["src/*.js"]);
const getMainFileAsList = () => globby(["src/index.js"]);
const getFileName = file =>
file
.split("/")
Expand All @@ -49,11 +50,11 @@ const config = (format, folder, minified = false) => input => ({
input,
output: {
file: `${folder ? folder + "/" : ""}${
format === "umd" ? getUmdOutput(input, minified) : getOutput(input, format === "es" ? "mjs" : "js")
format === "umd" ? getUmdOutput(input, minified) : getOutput(input, "js")
}`,
format,
sourcemap: true,
sourcemapFile: `${folder ? folder + "/" : ""}${getOutput(input, format === "es" ? "mjs" : "js")}.map`,
sourcemapFile: `${folder ? folder + "/" : ""}${getOutput(input, "js")}.map`,
strict: true,
banner: getActualBanner(),
name: format === "umd" ? "funCtional" : undefined
Expand All @@ -67,10 +68,11 @@ const config = (format, folder, minified = false) => input => ({
});

const sourceFiles = getSourceFilesList();
const mainFileAsList = getMainFileAsList();

export default [
...sourceFiles.map(config("cjs")),
...sourceFiles.map(config("es")),
...mainFileAsList.map(config("es", "esm")),
...sourceFiles.map(config("umd", "browser")),
...sourceFiles.map(config("umd", "browser", true))
];
2 changes: 1 addition & 1 deletion scripts/clean.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import del from "del";

const clean = async () =>
del(["browser", "*.js", "*.mjs", "*.map", "!babel.config.js", "!jest.config.js", "!rollup.config.js"]);
del(["browser", "esm", "*.js", "*.map", "!babel.config.js", "!jest.config.js", "!rollup.config.js"]);

// Makes the script crash on unhandled rejections instead of silently
// ignoring them. In the future, promise rejections that are not handled will
Expand Down