From 7f998d08e3ab8823c99190fa283bdfa2c4f2749b Mon Sep 17 00:00:00 2001 From: Lucas Fernandes Nogueira Date: Thu, 22 Apr 2021 15:39:59 -0300 Subject: [PATCH] fix(api): distribution (#1582) Co-authored-by: Amr Bashir <48618675+amrbashir@users.noreply.github.com> --- .changes/api-package-fix.md | 5 ++ tooling/api/{.eslintrc.js => .eslintrc.cjs} | 0 .../api/{.prettierrc.js => .prettierrc.cjs} | 0 tooling/api/package.json | 75 ++++++++++++++----- tooling/api/rollup.config.js | 4 +- 5 files changed, 65 insertions(+), 19 deletions(-) create mode 100644 .changes/api-package-fix.md rename tooling/api/{.eslintrc.js => .eslintrc.cjs} (100%) rename tooling/api/{.prettierrc.js => .prettierrc.cjs} (100%) diff --git a/.changes/api-package-fix.md b/.changes/api-package-fix.md new file mode 100644 index 000000000..c6973ce13 --- /dev/null +++ b/.changes/api-package-fix.md @@ -0,0 +1,5 @@ +--- +"api": patch +--- + +Fixes distribution of the `@tauri-apps/api` package for older bundlers. diff --git a/tooling/api/.eslintrc.js b/tooling/api/.eslintrc.cjs similarity index 100% rename from tooling/api/.eslintrc.js rename to tooling/api/.eslintrc.cjs diff --git a/tooling/api/.prettierrc.js b/tooling/api/.prettierrc.cjs similarity index 100% rename from tooling/api/.prettierrc.js rename to tooling/api/.prettierrc.cjs diff --git a/tooling/api/package.json b/tooling/api/package.json index 194316b34..b6d52d4b7 100644 --- a/tooling/api/package.json +++ b/tooling/api/package.json @@ -2,30 +2,71 @@ "name": "@tauri-apps/api", "version": "1.0.0-beta-rc.2", "description": "Tauri API definitions", - "main": "./index.js", - "typings": "./index.d.ts", + "type": "module", "exports": { - ".": "./index.js", - "./app": "./app.js", - "./cli": "./cli.js", - "./dialog": "./dialog.js", - "./event": "./event.js", - "./updater": "./updater.js", - "./fs": "./fs.js", - "./path": "./path.js", - "./http": "./http.js", - "./notification": "./notification.js", - "./tauri": "./tauri.js", - "./window": "./window.js", - "./shell": "./shell.js", - "./globalShortcut": "./globalShortcut.js" + ".": { + "import": "./index.js", + "require": "./index.cjs" + }, + "./app": { + "import": "./app.js", + "require": "./app.cjs" + }, + "./cli": { + "import": "./cli.js", + "require": "./cli.cjs" + }, + "./dialog": { + "import": "./dialog.js", + "require": "./dialog.cjs" + }, + "./event": { + "import": "./event.js", + "require": "./event.cjs" + }, + "./updater": { + "import": "./updater.js", + "require": "./updater.cjs" + }, + "./fs": { + "import": "./fs.js", + "require": "./fs.cjs" + }, + "./path": { + "import": "./path.js", + "require": "./path.cjs" + }, + "./http": { + "import": "./http.js", + "require": "./http.cjs" + }, + "./notification": { + "import": "./notification.js", + "require": "./notification.cjs" + }, + "./window": { + "import": "./window.js", + "require": "./window.cjs" + }, + "./shell": { + "import": "./shell.js", + "require": "./shell.cjs" + }, + "./globalShortcut": { + "import": "./globalShortcut.js", + "require": "./globalShortcut.cjs" + }, + "./tauri": { + "import": "./tauri.js", + "require": "./tauri.cjs" + } }, "funding": { "type": "opencollective", "url": "https://opencollective.com/tauri" }, "scripts": { - "build": "rimraf ./dist && rollup -c --silent && copyfiles package.json LICENSE* CHANGELOG.md dist", + "build": "rimraf ./dist && rollup -c --silent && copyfiles -f package.json LICENSE* CHANGELOG.md src/*.ts dist && copyfiles -f src/helpers/*.ts dist/helpers", "npm-pack": "yarn build && cd ./dist && npm pack", "npm-publish": "yarn build && cd ./dist && yarn publish --access public --loglevel silly", "lint": "eslint --ext ts \"./src/**/*.ts\"", diff --git a/tooling/api/rollup.config.js b/tooling/api/rollup.config.js index 371d80131..0790637ff 100644 --- a/tooling/api/rollup.config.js +++ b/tooling/api/rollup.config.js @@ -34,14 +34,14 @@ export default [ output: [ { dir: 'dist/', - entryFileNames: '[name].js', + entryFileNames: '[name].cjs', format: 'cjs', exports: 'named', globals: {} }, { dir: 'dist/', - entryFileNames: '[name].mjs', + entryFileNames: '[name].js', format: 'esm', exports: 'named', globals: {}