diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index bb3f18d..8101be3 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -15,15 +15,18 @@ This pull request adds everything the project needs to be at its first release. - [ ] Name the project: - Change `repo-name` in `.config` and ensure the tests pass. - Change the header of the documentation in `index.js`. - - Change the module name in `rollup.config.js`. + - Replace occurrences of `fluture-project` in `index.js`. + - Change the value of `output.name` in `rollup.config.js`. + - Replace occurrences of `flutureProject` in `index.js` to follow the value of `output.name` from the previous step. - [ ] Describe the project: - Change `description` in `package.json`. - Update the GitHub repo description. - - Add the description to the documentation in `index.js`. + - Update the description to the documentation in `index.js`. - Add additional `tags` in `package.json`. - [ ] If this is a node-only module, remove browser support: + - Remove browser usage instructions from the README. - Change `umd` to `cjs` in `rollup.config.js` and remove `output.name`. - Change `eslint-es3` to `eslint-es6` in `.eslintrc.json`. - Change `shared-node-browser` to `node` in `.eslintrc.json`. diff --git a/.gitignore b/.gitignore index 4c1ae26..ef4db68 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ /coverage/ -/index.cjs +/dist/* /node_modules/ + +!/dist/package.json diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0c9e5c1..86e6686 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -22,7 +22,10 @@ When adding a dependency, first consider whether to add it as a *regular* or as a *peer* dependency. -Make sure to update `rollup.config.js` after installing a new dependency. +Make sure to update `rollup.config.js` and the usage instructions in `index.js` +after installing a new dependency . Peer dependencies need to be included in the +`npm install` example, and all dependencies need to be mentioned in the UMD +scripting instructions. ### Regular Dependency diff --git a/dist/package.json b/dist/package.json new file mode 100644 index 0000000..5bbefff --- /dev/null +++ b/dist/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/index.js b/index.js index 7a7ae40..9a0e46a 100644 --- a/index.js +++ b/index.js @@ -1 +1,36 @@ //. # Fluture Project +//. +//. Hopefully something related to Fluture. +//. +//. ## Usage +//. +//. ### Node +//. +//. ```console +//. $ npm install --save fluture-project +//. ``` +//. +//. On Node 12 and up, this module can be loaded directly with `import` or +//. `require`. On Node versions below 12, `require` or the [esm][]-loader can +//. be used. +//. +//. ### Deno and Modern Browsers +//. +//. You can load the EcmaScript module from various content delivery networks: +//. +//. - [Skypack](https://cdn.skypack.dev/fluture-project@0.0.0) +//. - [JSPM](https://jspm.dev/fluture-project@0.0.0) +//. - [jsDelivr](https://cdn.jsdelivr.net/npm/fluture-project@0.0.0/+esm) +//. +//. ### Old Browsers and Code Pens +//. +//. There's a [UMD][] file included in the NPM package, also available via +//. jsDelivr: https://cdn.jsdelivr.net/npm/fluture-project@0.0.0/dist/umd.js +//. +//. This file adds `flutureProject` to the global scope, or use CommonJS/AMD +//. when available. + +export default void 0; + +//. [esm]: https://github.com/standard-things/esm +//. [UMD]: https://github.com/umdjs/umd diff --git a/package.json b/package.json index db40304..b5eeeeb 100644 --- a/package.json +++ b/package.json @@ -6,12 +6,12 @@ "fluture" ], "type": "module", - "main": "index.cjs", + "main": "./dist/umd.js", "module": "index.js", "exports": { ".": { "import": "./index.js", - "require": "./index.cjs" + "require": "./dist/umd.js" }, "./index.js": "./index.js" }, @@ -28,7 +28,7 @@ "url": "git://github.com/fluture-js/fluture-project.git" }, "files": [ - "/index.cjs", + "/dist", "/index.js", "/LICENSE", "/package.json", diff --git a/rollup.config.js b/rollup.config.js index 261cd8e..858dbf9 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,9 +1,18 @@ +import pkg from './package.json'; + +const dependencyNames = Array.prototype.concat.call ( + Object.keys (pkg.dependencies), + Object.keys (pkg.peerDependencies) +); + export default { input: 'index.js', + external: dependencyNames, output: { format: 'umd', - file: 'index.cjs', + file: 'dist/umd.js', name: 'flutureProject', - interop: false + exports: 'named', + globals: {} } };