mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-01 10:01:07 +02:00
fix(tauri.js) transpile TS API and fix cjs/esm export (#752)
This commit is contained in:
committed by
GitHub
parent
c8f430297f
commit
6301df660a
6
.changes/api-transpile.md
Normal file
6
.changes/api-transpile.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"tauri.js": patch
|
||||
---
|
||||
|
||||
Transpile the TS API to ES5.
|
||||
Expose CJS as .js and ESM as .mjs.
|
||||
@@ -1,13 +1,8 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist/",
|
||||
"strict": true,
|
||||
"module": "commonjs",
|
||||
"target": "es5",
|
||||
"allowJs": true,
|
||||
"esModuleInterop": true,
|
||||
"resolveJsonModule": true,
|
||||
"moduleResolution": "node",
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"types": ["@types"]
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
},
|
||||
"scripts": {
|
||||
"build": "yarn build:api && yarn build:typedefs && yarn build:webpack",
|
||||
"build:webpack": "webpack --progress",
|
||||
"build:api": "rollup -c --silent && yarn build:typedefs",
|
||||
"build:webpack": "rimraf ./dist && webpack --progress",
|
||||
"build:api": "rimraf ./api && rollup -c --silent && yarn build:typedefs",
|
||||
"build:typedefs": "yarn tsc ./api-src/index.ts --declaration --emitDeclarationOnly --outDir api",
|
||||
"build-release": "yarn build --display none --progress false",
|
||||
"test": "jest --runInBand --no-cache --testPathIgnorePatterns=\"(build|dev)\"",
|
||||
@@ -111,6 +111,7 @@
|
||||
"lockfile-lint": "4.3.7",
|
||||
"promise": "8.1.0",
|
||||
"raw-loader": "4.0.1",
|
||||
"rimraf": "^3.0.2",
|
||||
"rollup": "2.18.2",
|
||||
"rollup-plugin-terser": "6.1.0",
|
||||
"rollup-plugin-typescript2": "0.27.1",
|
||||
|
||||
@@ -3,7 +3,8 @@ import { terser } from 'rollup-plugin-terser'
|
||||
import resolve from '@rollup/plugin-node-resolve'
|
||||
import commonjs from '@rollup/plugin-commonjs'
|
||||
import sucrase from '@rollup/plugin-sucrase'
|
||||
import { getBabelOutputPlugin } from '@rollup/plugin-babel'
|
||||
import babel, { getBabelOutputPlugin } from '@rollup/plugin-babel'
|
||||
import typescript from '@rollup/plugin-typescript'
|
||||
import pkg from './package.json'
|
||||
|
||||
export default [{
|
||||
@@ -23,34 +24,39 @@ export default [{
|
||||
perf: true,
|
||||
output: [
|
||||
{
|
||||
dir: 'api/', // if you want to consume in node but want it tiny
|
||||
dir: 'api/',
|
||||
entryFileNames: '[name].js',
|
||||
format: 'cjs',
|
||||
plugins: [ terser() ],
|
||||
exports: 'named',
|
||||
globals: {}
|
||||
},
|
||||
{
|
||||
dir: 'api/esm/', // if you will be transpiling and minifying yourself
|
||||
entryFileNames: '[name].js',
|
||||
dir: 'api/',
|
||||
entryFileNames: '[name].mjs',
|
||||
format: 'esm',
|
||||
sourcemap: true,
|
||||
exports: 'named',
|
||||
globals: {}
|
||||
}
|
||||
],
|
||||
plugins: [
|
||||
commonjs({}),
|
||||
sucrase({
|
||||
exclude: ['node_modules'],
|
||||
transforms: ['typescript']
|
||||
}),
|
||||
resolve({
|
||||
// pass custom options to the resolve plugin
|
||||
customResolveOptions: {
|
||||
moduleDirectory: 'node_modules'
|
||||
}
|
||||
})
|
||||
}),
|
||||
typescript({
|
||||
tsconfig: './api-src/tsconfig.json'
|
||||
}),
|
||||
babel({
|
||||
configFile: false,
|
||||
presets: [
|
||||
['@babel/preset-env'],
|
||||
['@babel/preset-typescript']
|
||||
]
|
||||
}),
|
||||
terser()
|
||||
],
|
||||
external: [
|
||||
...Object.keys(pkg.dependencies || {}),
|
||||
|
||||
@@ -8200,7 +8200,7 @@ rimraf@^2.5.4, rimraf@^2.6.3:
|
||||
dependencies:
|
||||
glob "^7.1.3"
|
||||
|
||||
rimraf@^3.0.0:
|
||||
rimraf@^3.0.0, rimraf@^3.0.2:
|
||||
version "3.0.2"
|
||||
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a"
|
||||
integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==
|
||||
|
||||
Reference in New Issue
Block a user