Skip to content

Commit

Permalink
v1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
shuritch committed Mar 18, 2024
1 parent 63341d1 commit 8c8f97e
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 17 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ jobs:
matrix:
node:
- 18
- 19
- 20
os:
- ubuntu-latest
Expand Down
14 changes: 12 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

## [Unreleased][unreleased]

## [1.4.0][] - 2024-03-18

- Packages update
- Makefile actions runner
- Default export hack for ESM support
- Removed support of Nodejs v19
- Documentation for ./dist folder

## [1.3.0][] - 2023-11-26

- Packages update
Expand Down Expand Up @@ -30,8 +38,10 @@
- Stable release version
- Repository created

[unreleased]: https://github.com/astrohelm/workspace/compare/v1.2.0...HEAD
[1.1.1]: https://github.com/astrohelm/workspace/compare/v1.1.1...v1.2.0
[unreleased]: https://github.com/astrohelm/workspace/compare/v1.4.0...HEAD
[1.4.0]: https://github.com/astrohelm/workspace/compare/v1.3.0...v1.4.0
[1.3.0]: https://github.com/astrohelm/workspace/compare/v1.2.0...v1.3.0
[1.2.0]: https://github.com/astrohelm/workspace/compare/v1.1.1...v1.2.0
[1.1.1]: https://github.com/astrohelm/workspace/compare/v1.1.0...v1.1.1
[1.1.0]: https://github.com/astrohelm/workspace/compare/release...v1.1.0
[1.0.0]: https://github.com/astrohelm/workspace/releases/tag/release
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ message = First commit
data = data
repo = workspace

actions:
act -q

search-strings:
grep -Hrn '${search}' ${path}

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,16 @@ Congratulations, package initialized 🚀

This workspace have commonjs in use by default. You can switch it in package.json if you want.

- `dist` directory used for fronted package analog. You can use it if your package is multi-platform
based.
- `dist` directory used for fronted package analog. You can use it if your package is
multi-platform, [readme](./dist/README.md).
- `eslint` astrohelm eslint rules
- `types` .d.ts library types exports
- `CHANGELOG.md` in use for project history documentation
- `Makefile` ultimate commands shortcuts creator
- `tests` here you can put all test coverage of your package
- `.github` github ci pipeline by default
- `lib` folder should contain all you library logic, _WARNING !_ Remove if you not writing library.
Replace with src folder.
- `lib` folder should contain all you library logic,**_WARNING !_** Remove if you not writing
library. Replace with **src** folder.

<h2 align="center">Copyright & contributors</h2>

Expand Down
110 changes: 110 additions & 0 deletions dist/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# How to setup workspace with builder

> [!TIP]
>
> In this example we will create workspace for frontend / backend library;
> This library would be accessible from any browser & nodejs.

## Install rollup:

Also we install here dependency for rollup that will transliterate our commonjs modules to esm.


```bash
npm i -D rollup @rollup/plugin-commonjs
```

## Creating gateway file:

> [!IMPORTANT]
>
> Before we will create our config - i want to create special file for exports regulation.
> You can skip this step and fill input with your **entry point** javascript file.
```js
// ./dist/exports.js
'use strict';

const exp = {
module1: require('./path/to/module1.js'),
module2: require('./path/to/module2.js'),
}

module.exports = exp;
module.exports.default = exp; // For default export
```

## Writing rollup configuration:

> [!IMPORTANT]
>
> Use you own rollup configuration, this configuration should be only your entry point configuration.
> This configuration used to create cross-platform **(browser / nodejs)** libraries.
```js
// ./dist/rollup.config.js
'use strict';

module.exports = {
input: ['./dist/exports.js'], // Our entry point
output: {
file: './dist/index.js',
format: 'es',
},
plugins: [[require('@rollup/plugin-commonjs')()]],
};
```

## Finish moves:

> [!IMPORTANT]
>
> Add build script to your **package.json** file and enjoy.
```json
{
// package.json
// ...
"scripts": {
"build": "rollup -c ./dist/rollup.config.js",
//...
}
}
```

### Result / Testing

> [!IMPORTANT]
>
> If you done all correctly - all should be working.
> You can test it with next bash script:
```bash
npm run build
# Check ./dist folder for results
ls ./dist
# You will see index.js
cat ./dist/index.js
# Your code
# ...
# export { exports as default, module1, module2 }
```

### Optional

> [!IMPORTANT]
>
> If you do all steps with me and want browser support -
> You can add browser exports to your **package.json**.
```json
{
// package.json
// ...
"browser": {
"./index.js": "./dist/index.js",
//...
}
}
```
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

const lib = require('./lib');

module.exports = { lib };
module.exports.default = module.exports = lib;
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"license": "MIT",
"version": "1.3.0",
"version": "1.4.0",
"type": "commonjs",
"name": "astrohelm-workspace",
"homepage": "https://astrohelm.ru",
Expand Down Expand Up @@ -43,13 +43,13 @@
},

"devDependencies": {
"@types/node": "^20.10.0",
"eslint": "^8.54.0",
"eslint-config-astrohelm": "^1.2.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-prettier": "^5.0.1",
"prettier": "^3.1.0",
"typescript": "^5.3.2"
"@types/node": "^20.11.28",
"eslint": "^8.57.0",
"eslint-config-astrohelm": "^1.3.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-prettier": "^5.1.3",
"prettier": "^3.2.5",
"typescript": "^5.4.2"
}
}

0 comments on commit 8c8f97e

Please sign in to comment.