Skip to content

Commit

Permalink
added first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Allan-Nava authored Oct 11, 2023
1 parent 01f576e commit c1c1eb2
Show file tree
Hide file tree
Showing 5 changed files with 159 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Cypress Tests

on: [push]

jobs:
cypress-run:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
# Install NPM dependencies, cache them correctly
# and run all Cypress tests
- name: Cypress run
uses: cypress-io/github-action@v4
with:
build: npm run build
start: npm start
11 changes: 11 additions & 0 deletions lib/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
*
* Author: Allan Nava ([email protected])
* -----
* Last Modified:
* Modified By: Allan Nava ([email protected]>)
* -----
* Copyright 2023 - 2023 ©
*
*
*/
35 changes: 35 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "compress-nodejs",
"private": true,
"version": "0.1.0",
"description": "",
"main": "dist/index.js",
"browser": "dist/index.js",
"module": "dist/index.esm.js",
"files": [
"dist/**/*"
],
"scripts": {
"build": "rimraf dist && rollup --config --bundleConfigAsCjs",
"tsc": "tsc",
"prepublishOnly": "npm run build",
"prepare": "npm run build"
},
"peerDependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0",
"moment": "^2.29.4",
"next": ">=13.0.0"
},
"devDependencies": {
"@rollup/plugin-node-resolve": "^15.0.1",
"@types/react": "18.0.9",
"rollup": "^3.2.5",
"babel-loader": "^8.2.2",
"rimraf": "^3.0.2",
"rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-typescript2": "^0.31.1",
"tslib": "^2.4.1"
}
}

61 changes: 61 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import resolve from "@rollup/plugin-node-resolve";
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
import pkg from "./package.json";
import typescript from 'rollup-plugin-typescript2';

const commonOutputOptions = {
dir: "dist",
preserveModules: true,
preserveModulesRoot: "lib",
};

function getOutputOptions(options) {
return {
...commonOutputOptions,
...options,
};
}

function withSourceMapOutputOptions(options) {
return {
...options,
sourcemap: true,
};
}

function getCJSOutputOptions(options) {
return {
...getOutputOptions(options),
format: "cjs",
exports: "named",
};
}

function getESMOutputOptions(options) {
return {
...getOutputOptions(options),
format: "esm",
};
}

export default {
input: ["lib/index.ts"],
output: [
// ESM
getESMOutputOptions(
withSourceMapOutputOptions({
entryFileNames: "[name].esm.js",
})
),
// CommonJS
getCJSOutputOptions(
withSourceMapOutputOptions({})
)
],
plugins: [
peerDepsExternal(),
resolve(),
typescript(),
],
external: Object.keys(pkg.peerDependencies),
};
35 changes: 35 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"include": [
"lib/**/*.ts",
"lib/**/*.tsx"
],
"exclude": [
"node_modules",
"dist",
],
"compilerOptions": {
"target": "es5",
"module": "esnext",
"lib": [
"dom.iterable",
"dom",
"esnext"
],
"allowJs": false,
"jsx": "react",
"declaration": true,
"sourceMap": true,
"outDir": "dist",
"rootDir": "lib",
"baseUrl": "lib",
"removeComments": true,
"strict": false,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
}
}

0 comments on commit c1c1eb2

Please sign in to comment.