Skip to content
This repository has been archived by the owner on Dec 11, 2023. It is now read-only.

Commit

Permalink
[chore] Launch NPM Package (#2)
Browse files Browse the repository at this point in the history
* Setup Rollup

* Build with SWC

* Minify

* Update Package.json
  • Loading branch information
AsPulse authored Mar 5, 2023
1 parent 51c09a9 commit 7fbf5d8
Show file tree
Hide file tree
Showing 5 changed files with 1,174 additions and 20 deletions.
18 changes: 17 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
{
"name": "sugarform",
"version": "1.0.0",
"version": "0.0.0",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"files": [
"package.json",
"LICENSE",
"dist"
],
"repository": "https://github.com/sugarform-dev/sugarform.git",
"author": "aspulse <[email protected]>",
"license": "MIT",
"packageManager": "[email protected]",
"devDependencies": {
"@rollup/plugin-commonjs": "^24.0.1",
"@rollup/plugin-typescript": "^11.0.0",
"@swc/core": "^1.3.37",
"@types/react": "^18.0.28",
"@typescript-eslint/eslint-plugin": "^5.54.0",
"@typescript-eslint/parser": "^5.54.0",
Expand All @@ -16,6 +25,10 @@
"eslint-plugin-unused-imports": "^2.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"rollup": "^3.18.0",
"rollup-plugin-dts": "^5.2.0",
"rollup-plugin-swc3": "^0.8.0",
"tslib": "^2.5.0",
"typescript": "^4.9.5"
},
"peerDependencies": {
Expand All @@ -27,5 +40,8 @@
"@types/react": {
"optional": true
}
},
"scripts": {
"build": "rollup -c"
}
}
46 changes: 46 additions & 0 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/* eslint-disable no-restricted-exports */
import commonjs from '@rollup/plugin-commonjs';
import dts from 'rollup-plugin-dts';
import { swc, defineRollupSwcOption, minify, defineRollupSwcMinifyOption } from 'rollup-plugin-swc3';
import packageJson from './package.json' assert { type: 'json' };

export default [
{
input: 'src/index.ts',
output: [
{
file: packageJson.main,
format: 'cjs',
sourcemap: false,
},
{
file: packageJson.module,
format: 'esm',
sourcemap: false,
},
],
plugins: [
commonjs({
include: [ 'node_modules/**' ],
}),
swc(defineRollupSwcOption({
exclude: /__tests__/,
})),
minify(defineRollupSwcMinifyOption({
compress: true,
mangle: true,
})),
],
external: [ 'react', 'react-dom' ],
},
{
input: 'dist/cjs/types/index.d.ts',
output: [{ file: 'dist/cjs/index.d.ts', format: 'cjs' }],
plugins: [ dts() ],
},
{
input: 'dist/esm/types/index.d.ts',
output: [{ file: 'dist/esm/index.d.ts', format: 'esm' }],
plugins: [ dts() ],
},
];
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export function helloSugarForm(): void {
console.log('Hello, Sugar Form!');
return;
}
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "ES5",
"target": "ES2015",
"module": "ESNext",
"outDir": "dist",
"rootDir": "./src",
Expand All @@ -27,6 +27,6 @@
"noFallthroughCasesInSwitch": true,
"noUncheckedIndexedAccess": true
},
"include": ["src", ".eslintrc.cjs"],
"include": ["src", ".eslintrc.cjs", "rollup.config.mjs"],
"exclude": ["node_modules", "dist"]
}
Loading

0 comments on commit 7fbf5d8

Please sign in to comment.