Skip to content

Commit

Permalink
fix: separate cjs and mjs typings
Browse files Browse the repository at this point in the history
  • Loading branch information
adrai committed Nov 10, 2023
1 parent 7dc2a70 commit 01b6626
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 6.4.0

- fix: separate cjs and mjs typings

### 6.3.1

- fix for browser usage
Expand Down
8 changes: 8 additions & 0 deletions index.d.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import * as index from './index.js';

export default index.default;

export type LocizeBackendOptions = index.LocizeBackendOptions;
export type RequestResponse = index.RequestResponse;
export type RequestCallback = index.RequestCallback;
export type CustomRequestOptions = index.CustomRequestOptions;
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,20 @@
"types": "./index.d.ts",
"devDependencies": {
"@babel/cli": "7.23.0",
"@babel/core": "7.23.2",
"@babel/preset-env": "7.23.2",
"@babel/core": "7.23.3",
"@babel/preset-env": "7.23.3",
"babel-plugin-add-module-exports": "1.0.4",
"browserify": "17.0.0",
"dtslint": "4.2.1",
"eslint": "8.52.0",
"eslint": "8.53.0",
"eslint-config-standard": "17.1.0",
"eslint-plugin-import": "2.29.0",
"eslint-plugin-n": "16.2.0",
"eslint-plugin-n": "16.3.1",
"eslint-plugin-promise": "6.1.1",
"eslint-plugin-require-path-exists": "1.1.9",
"eslint-plugin-standard": "5.0.0",
"expect.js": "0.3.1",
"i18next": "23.6.0",
"i18next": "23.7.1",
"json-server": "0.17.4",
"mocha": "10.2.0",
"tslint": "5.20.1",
Expand All @@ -67,7 +67,7 @@
},
"scripts": {
"lint": "eslint .",
"compile:esm": "rm -rf esm && mkdir esm && BABEL_ENV=esm babel lib -d esm && cp index.d.ts esm/index.d.ts && cp lib/getFetch.cjs esm/getFetch.cjs && rm -f esm/getFetch.js && node -e \"fs.writeFileSync('esm/getFetch.cjs', fs.readFileSync('esm/getFetch.cjs').toString().replace('/* eslint-disable no-var, no-undef */\\n', ''))\"",
"compile:esm": "rm -rf esm && mkdir esm && BABEL_ENV=esm babel lib -d esm && cp index.d.ts esm/index.d.ts && cp index.d.mts esm/index.d.mts && cp lib/getFetch.cjs esm/getFetch.cjs && rm -f esm/getFetch.js && node -e \"fs.writeFileSync('esm/getFetch.cjs', fs.readFileSync('esm/getFetch.cjs').toString().replace('/* eslint-disable no-var, no-undef */\\n', ''))\"",
"compile:cjs": "rm -rf cjs && mkdir cjs && BABEL_ENV=cjs babel lib -d cjs && cp index.d.ts cjs/index.d.ts && echo '{\"type\":\"commonjs\"}' > cjs/package.json && cp lib/getFetch.cjs cjs/getFetch.js && node -e \"fs.writeFileSync('cjs/getFetch.js', fs.readFileSync('cjs/getFetch.js').toString().replace('/* eslint-disable no-var, no-undef */\\n', ''))\" && node -e \"fs.writeFileSync('cjs/request.js', fs.readFileSync('cjs/request.js').toString().replace('getFetch.cjs', 'getFetch.js'))\"",
"compile": "npm run compile:esm && npm run compile:cjs",
"browser": "browserify --ignore cross-fetch --standalone i18nextLocizeBackend cjs/index.js -o i18nextLocizeBackend.js && uglifyjs i18nextLocizeBackend.js --compress --mangle -o i18nextLocizeBackend.min.js",
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
"strict": true,
"noEmit": true,
"baseUrl": ".",
"paths": { "i18next-locize-backend": ["./index.d.ts"] },
"paths": { "i18next-locize-backend": ["./index.d.mts"] },

"esModuleInterop": true,
"allowSyntheticDefaultImports": true
},
"include": ["./index.d.ts", "./test/**/*"],
"include": ["./index.d.mts", "./test/**/*"],
"exclude": []
}

0 comments on commit 01b6626

Please sign in to comment.