Skip to content

Commit

Permalink
Merge pull request #8 from tokens-studio/prebundle-postcss-utils
Browse files Browse the repository at this point in the history
fix: prebundle CJS-only dependency to ESM
  • Loading branch information
jorenbroekema authored Jan 20, 2023
2 parents ce9ef3a + 631424d commit 4de51a9
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/wild-emus-yawn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tokens-studio/sd-transforms': patch
---

No longer need to commit to using @rollup/plugin-commonjs. We prebundle the dependency that is CJS-only so users don't need to worry about it.
20 changes: 18 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
node_modules
coverage/
## editors
/.idea
/.vscode
/*.code-workspace
/.history

## system files
.DS_Store

## npm/yarn
node_modules/
npm-debug.log

## temp folders
/coverage/

index.cjs
src/postcss-calc-ast-parser.js
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ npm-debug.log
## temp folders
/coverage/

index.cjs
index.cjs
src/postcss-calc-ast-parser.js
18 changes: 18 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## editors
/.idea
/.vscode
/*.code-workspace
/.history

## system files
.DS_Store

## npm/yarn
node_modules/
npm-debug.log

## temp folders
/coverage/

index.cjs
src/postcss-calc-ast-parser.js
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ to work with Design Tokens that are exported from [Tokens Studio](https://tokens
- Transform Tokens Studio shadow objects to CSS shadow format
- Registers these transforms, in addition to `attribute/cti`, `name/cti/camelCase` for naming purposes, as a transform group called `tokens-studio`

> If you consume this library using ESM, I am afraid that you will need something like `@rollup/plugin-commonjs` to deal with the fact that I am reliant on a CJS-written library called `postcss-calc-ast-parser` and its dependency `postcss-value-parser`.
> I will look into creating a PR to those repos to bundle as `mjs` and publish that, or publish it through a fork.
## Usage

```js
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"src/**/*"
],
"scripts": {
"esm-postcss-calc": "rollup node_modules/postcss-calc-ast-parser/dist/index.js --file src/postcss-calc-ast-parser.js --format esm --plugin @rollup/plugin-commonjs --plugin @rollup/plugin-node-resolve",
"build:cjs": "rollup index.js --file index.cjs --format cjs --plugin @rollup/plugin-commonjs --plugin rollup-plugin-cleanup --plugin @rollup/plugin-node-resolve",
"build:types": "tsc -p tsconfig.build.types.json",
"format": "npm run format:eslint && npm run format:prettier",
Expand All @@ -26,7 +27,7 @@
"lint:eslint": "eslint --ext .js,.html .",
"lint:prettier": "prettier \"**/*.js\" --list-different || (echo '↑↑ these files are not prettier formatted ↑↑' && exit 1)",
"lint:types": "tsc",
"release": "run-p build:* && changeset publish",
"release": "npm run esm-postcss-calc && run-p build:* && changeset publish",
"prepare": "husky install"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
"suppressImplicitAnyIndexErrors": true
},
"include": ["**/*.js"],
"exclude": ["node_modules", "**/coverage/*"]
"exclude": ["node_modules", "**/coverage/*", "src/postcss-calc-ast-parser.js"]
}

0 comments on commit 4de51a9

Please sign in to comment.