Skip to content

Commit

Permalink
fix(deps): update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
mkosir committed Jan 21, 2024
1 parent f1c34e5 commit 5ab7bea
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 33 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"name": "react-parallax-tilt",
"description": "Easily apply tilt hover effect on React components - lightweight/zero dependencies",
"version": "0.0.0-development",
"version": "0.0.0",
"type": "module",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"types": "./dist/legacy/index.d.ts",
"module": "./dist/legacy/index.js",
"main": "./dist/legacy/index.cjs",
"exports": {
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.mjs"
"types": "./dist/modern/index.d.ts",
"default": "./dist/modern/index.js"
},
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
"types": "./dist/modern/index.d.cts",
"default": "./dist/modern/index.cjs"
}
},
"files": [
Expand Down
104 changes: 81 additions & 23 deletions rollup.config.ts
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
import commonjs from '@rollup/plugin-commonjs';
import terser from '@rollup/plugin-terser';
import typescript from '@rollup/plugin-typescript';
import { defineConfig } from 'rollup';
import { defineConfig, RollupOptions } from 'rollup';
import { dts } from 'rollup-plugin-dts';

import packageJson from './package.json' assert { type: 'json' };
import tsConfig from './tsconfigs/tsconfig.base.json' assert { type: 'json' };

const isProduction = process.env.NODE_ENV === 'production';
const IS_PRODUCTION = process.env.NODE_ENV === 'production';

const inputFile = 'src/index.ts';
const PATH_INPUT_FILE = 'src/index.ts';
const PATH_TSCONFIG = './tsconfigs/tsconfig.prod.json';

const rollupConfig = defineConfig([
const GLOBALS = {
react: 'React',
'react-dom': 'ReactDOM',
} as const;

const LEGACY_CONFIG = [
{
input: inputFile,
input: PATH_INPUT_FILE,
output: [
{
file: packageJson.module,
format: 'esm',
sourcemap: !IS_PRODUCTION,
globals: GLOBALS,
},
{
file: packageJson.main,
name: packageJson.name,
format: 'umd',
sourcemap: !isProduction,
globals: {
react: 'React',
'react-dom': 'ReactDOM',
},
},
{
file: packageJson.module,
format: 'esm',
sourcemap: !isProduction,
globals: {
react: 'React',
'react-dom': 'ReactDOM',
},
sourcemap: !IS_PRODUCTION,
globals: GLOBALS,
},
],
plugins: [
commonjs(),
typescript({
tsconfig: './tsconfigs/tsconfig.prod.json',
sourceMap: !isProduction,
tsconfig: PATH_TSCONFIG,
sourceMap: !IS_PRODUCTION,
}),
terser({
output: { comments: false },
Expand All @@ -56,7 +56,7 @@ const rollupConfig = defineConfig([
],
},
{
input: inputFile,
input: PATH_INPUT_FILE,
output: { file: packageJson.types, format: 'esm' },
plugins: [
dts({
Expand All @@ -67,7 +67,65 @@ const rollupConfig = defineConfig([
}),
],
},
]);
] as const satisfies ReadonlyArray<RollupOptions>;

const MODERN_CONFIG = [
{
input: PATH_INPUT_FILE,
output: [
{
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
file: packageJson.exports.import.default,
format: 'esm',
sourcemap: !IS_PRODUCTION,
globals: GLOBALS,
},
{
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
file: packageJson.exports.require.default,
name: packageJson.name,
format: 'umd',
sourcemap: !IS_PRODUCTION,
globals: GLOBALS,
},
],
plugins: [
commonjs(),
typescript({
tsconfig: PATH_TSCONFIG,
sourceMap: !IS_PRODUCTION,
}),
terser({
output: { comments: false },
compress: {
pure_getters: true,
},
toplevel: true,
}),
],
// Ensure dependencies are not bundled with the library
external: [...Object.keys(packageJson.peerDependencies)],
},
{
input: PATH_INPUT_FILE,
output: [
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
{ file: packageJson.exports.import.types, format: 'esm' },
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
{ file: packageJson.exports.require.types, format: 'cjs' },
],
plugins: [
dts({
compilerOptions: {
baseUrl: './src',
paths: tsConfig.compilerOptions.paths,
},
}),
],
},
] as const satisfies ReadonlyArray<RollupOptions>;

const rollupConfig = defineConfig([...LEGACY_CONFIG, ...MODERN_CONFIG]);

// eslint-disable-next-line
export default rollupConfig;

0 comments on commit 5ab7bea

Please sign in to comment.