Skip to content

Commit 54f8f64

Browse files
committed
Big changes to the package
- Export the plugin as the default module to increase its compatibility - Export the options helpers in a separated options module - Get rid of the dist folder to publish the package
1 parent 431cc05 commit 54f8f64

19 files changed

+83
-32
lines changed

.gitignore

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
node_modules/
22
dist/
33
.DS_Store
4-
coverage/
4+
coverage/
5+
/@types/
6+
/constants/
7+
/data/
8+
/parsers/
9+
/utilities/
10+
/index.d.ts
11+
/index.js
12+
/options.d.ts
13+
/options.js

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ script:
1111
- rm -rf ./coverage
1212
before_deploy:
1313
- yarn build
14+
- yarn copy
1415
deploy:
1516
edge: true
1617
provider: npm

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## [3.0.0] - 2021-01-29
4+
5+
- Export the plugin as the default module to increase its compatibility
6+
- Export the options helpers in a separated options module
7+
- Get rid of the dist folder to publish the package
8+
39
## [2.0.0] - 2020-12-16
410

511
- Updated packages to the latest versions and solved vulnerabilities

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Basic usage
3535

3636
```bash
3737
const postcss = require('postcss');
38-
const { postcssRTLCSS } = require('postcss-rtlcss');
38+
const postcssRTLCSS = require('postcss-rtlcss');
3939

4040
const options = { ... available options ... };
4141
const result = postcss([
@@ -49,7 +49,7 @@ const rtlCSS = result.css;
4949
5050
```bash
5151
import postcss from 'postcss';
52-
import { postcssRTLCSS } from 'postcss-rtlcss';
52+
import postcssRTLCSS from 'postcss-rtlcss';
5353

5454
const options = { ... available options ... };
5555
const result = postcss([
@@ -318,7 +318,8 @@ The mode option has been explained in the [Output using the combined mode](#outp
318318
319319
```javascript
320320
import postcss from 'postcss';
321-
import { postcssRTLCSS, Mode } from 'postcss-rtlcss';
321+
import postcssRTLCSS from 'postcss-rtlcss';
322+
import { Mode } from 'postcss-rtlcss/options';
322323
323324
const input = '... css code ...';
324325
const optionsCombined = { mode: Mode.combined }; // This is the default value
@@ -586,7 +587,7 @@ This option manages if the conversion will be from `LTR` to `RTL` or vice versa.
586587
##### Using Source.ltr in combined mode
587588
588589
```javascript
589-
import { Mode, Source } from 'postcss-rtlcss';
590+
import { Mode, Source } from 'postcss-rtlcss/options';
590591
591592
const options = {
592593
mode: Mode.combined,
@@ -609,7 +610,7 @@ const options = {
609610
##### Using Source.rtl in override mode
610611
611612
```javascript
612-
import { Mode, Source } from 'postcss-rtlcss';
613+
import { Mode, Source } from 'postcss-rtlcss/options';
613614
614615
const options = {
615616
mode: Mode.override,
@@ -929,7 +930,7 @@ Flip or not the selectors names of the rules without directional properties usin
929930
##### Using Autorename.flexible
930931
931932
```javascript
932-
import { Autorename } from 'postcss-rtlcss';
933+
import { Autorename } from 'postcss-rtlcss/options';
933934
934935
const options = {
935936
autoRename: Autorename.flexible
@@ -955,7 +956,7 @@ const options = {
955956
##### Using Autorename.strict
956957
957958
```javascript
958-
import { Autorename } from 'postcss-rtlcss';
959+
import { Autorename } from 'postcss-rtlcss/options';
959960
960961
const options = {
961962
autoRename: Autorename.strict
@@ -1007,7 +1008,7 @@ When `autoRename` is enabled and greedy is `true`, the strings replacements will
10071008
##### greedy false
10081009
10091010
```javascript
1010-
import { Autorename } from 'postcss-rtlcss';
1011+
import { Autorename } from 'postcss-rtlcss/options';
10111012
10121013
const options = {
10131014
autoRename: Autorename.flexible,
@@ -1030,7 +1031,7 @@ const options = {
10301031
##### greedy true
10311032
10321033
```javascript
1033-
import { Autorename } from 'postcss-rtlcss';
1034+
import { Autorename } from 'postcss-rtlcss/options';
10341035
10351036
const options = {
10361037
autoRename: Autorename.flexible,

package.json

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,25 @@
1313
"postcss-rtlcss",
1414
"rtlcss"
1515
],
16-
"main": "dist/index.js",
17-
"types": "dist/index.d.ts",
16+
"main": "index.js",
17+
"types": "index.d.ts",
1818
"files": [
19-
"dist/**/*"
19+
"@types/**/*",
20+
"constants/**/*",
21+
"data/**/*",
22+
"parsers/**/*",
23+
"utilities/**/*",
24+
"index.d.ts",
25+
"index.js",
26+
"options.d.ts",
27+
"options.js"
2028
],
2129
"scripts": {
2230
"test": "jest --clearCache && jest --verbose",
2331
"lint": "eslint src/**/*.ts",
24-
"build": "webpack && tscpaths -p tsconfig.json -s ./src -o ./dist",
25-
"prepare": "npm run build",
32+
"copy": "cp -r ./dist/. ./",
33+
"build": "webpack && tscpaths -p tsconfig.json -s ./src -o ./dist && yarn copy",
34+
"prepare": "yarn build && yarn copy",
2635
"prepublishOnly": "npm run lint && npm run test",
2736
"version": "git add .",
2837
"postversion": "git push && git push --tags"

src/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ import { initStore } from '@data/store';
44
import { parseKeyFrames, parseAtRules } from '@parsers/atrules';
55
import { parseRules } from '@parsers/rules';
66
import { appendRules, appendKeyFrames, appendAutorenameRules } from '@utilities/rules';
7-
export { PluginOptions, Mode, Source, PluginStringMap, Autorename } from '@types';
87

9-
export const postcssRTLCSS = (options: PluginOptions = {}): Plugin => ({
8+
const postcssRTLCSS = (options: PluginOptions = {}): Plugin => ({
109
postcssPlugin: 'postcss-rtlcss',
1110
Once(css: Root): void {
1211
initStore(options);
@@ -19,4 +18,6 @@ export const postcssRTLCSS = (options: PluginOptions = {}): Plugin => ({
1918
}
2019
});
2120

22-
postcssRTLCSS.postcss = true;
21+
postcssRTLCSS.postcss = true;
22+
23+
export default postcssRTLCSS;

src/options.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { Mode, Source, Autorename } from '@types';
2+
3+
export default {
4+
Mode,
5+
Source,
6+
Autorename
7+
};

tests/combined-autorename.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import postcss from 'postcss';
2-
import { postcssRTLCSS, PluginOptions, Mode, Autorename } from '../src';
2+
import postcssRTLCSS from '../src';
3+
import { PluginOptions, Mode, Autorename } from '../src/@types';
34
import { readCSSFile } from './test-utils';
45

56
const baseOptions: PluginOptions = {mode: Mode.combined};

tests/combined-basic-options.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import postcss from 'postcss';
2-
import { postcssRTLCSS, PluginOptions, Mode, Source } from '../src';
2+
import postcssRTLCSS from '../src';
3+
import { PluginOptions, Mode, Source } from '../src/@types';
34
import { readCSSFile } from './test-utils';
45

56
const baseOptions: PluginOptions = {mode: Mode.combined};

tests/combined-prefixes.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import postcss from 'postcss';
2-
import { postcssRTLCSS, PluginOptions, Mode } from '../src';
2+
import postcssRTLCSS from '../src';
3+
import { PluginOptions, Mode } from '../src/@types';
34
import { readCSSFile } from './test-utils';
45

56
const baseOptions: PluginOptions = {mode: Mode.combined};

0 commit comments

Comments
 (0)