Skip to content

Commit

Permalink
chore: optimize packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
z0gSh1u committed Aug 28, 2024
1 parent 273cb3e commit 7efee8a
Show file tree
Hide file tree
Showing 4 changed files with 944 additions and 297 deletions.
12 changes: 6 additions & 6 deletions packages/secretnote-lite/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@alipay/secretnote-lite",
"version": "0.0.40",
"version": "0.0.42",
"license": "Apache-2.0",
"author": "vectorse@126.com",
"repository": "https://github.com/secretflow/secretnote/tree/main/packages/secretnote",
Expand All @@ -9,12 +9,12 @@
"dist",
"src"
],
"main": "index.js",
"module": "index.js",
"types": "index.d.ts",
"main": "dist/index.js",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"setup": "tsup src/index.tsx",
"build": "tsup src/index.tsx",
"build": "tsup src/index.tsx --inject ./react-shim.js",
"dev": "tsup src/index.tsx --watch",
"lint:eslint": "eslint src",
"lint:stylelint": "stylelint 'src/**/*.{css,less}'",
Expand Down Expand Up @@ -81,4 +81,4 @@
"publishConfig": {
"registry": "https://registry.antgroup-inc.cn"
}
}
}
2 changes: 2 additions & 0 deletions packages/secretnote-lite/react-shim.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import React from 'react';
export { React };
10 changes: 8 additions & 2 deletions packages/secretnote-lite/tsup.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { spawn } = require('child_process');
const { copyFileSync } = require('fs');
const { writeFileSync } = require('fs');
const { yellow } = require('colorette');
const svgr = require('esbuild-plugin-svgr');
const { defineConfig } = require('tsup');
Expand Down Expand Up @@ -33,16 +33,22 @@ const emitDeclarations = (outDir) =>
proc.on('error', reject);
});

const dtsIndex = `declare const App: () => JSX.Element;
export { App as default };`;

module.exports = defineConfig((overrides) => ({
outDir: 'dist',
format: ['esm'], //, 'cjs'],
outExtension: () => ({ js: `.js` }),
sourcemap: true,
dts: true,
dts: false,
loader: {
'.less': 'copy',
'.md': 'text',
},
esbuildPlugins: [svgr()],
onSuccess() {
writeFileSync('./dist/index.d.ts', dtsIndex);
},
clean: overrides.clean || !overrides.watch,
}));
Loading

0 comments on commit 7efee8a

Please sign in to comment.