Fixed error with exports

This commit is contained in:
minicx 2023-08-18 22:01:16 +03:00
parent 80be3ed967
commit b8d3b5eb84
8 changed files with 106 additions and 56 deletions

View File

@ -1,4 +1,5 @@
{
"$schema": "https://json.schemastore.org/eslintrc",
"extends": [
"eslint:recommended",
"plugin:unicorn/recommended",
@ -8,8 +9,13 @@
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
"project": true
},
"root": true,
"ignorePatterns":[
"dist/"
],
"plugins": [
"@typescript-eslint",
"unicorn",

5
.gitignore vendored
View File

@ -11,4 +11,7 @@ dist
# Logs
*.log*
*.log*
.vscode

View File

@ -24,11 +24,11 @@ npm install flaresolverr.js # or yarn add flaresolverr.js
## Usage:
```typescript
const FlareSolverr = require('flaresolverr.js');
const { FlareSolverr } = require('flaresolverr.js');
/*
Also you can import this library via esm syntax:
import FlareSolverr from "Flaresolverr.js"
import { FlareSolverr } from "Flaresolverr.js"
*/
// Initialize FlareSolverr with the API endpoint URL

View File

@ -1,16 +1,20 @@
{
"name": "flaresolverr.js",
"version": "0.0.1",
"type": "module",
"description": "Api for dockered FlareSolverr",
"main": "./dist/cjs/index.js",
"module": "./dist/mjs/index.js",
"types": "./dist/index.d.ts",
"description": "Api for bypassing cloudflare via dockered FlareSolverr",
"files": [
"dist",
"README.md",
"LICENSE"
],
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"exports": {
"import": "./dist/index.mjs",
"require": "./dist/index.cjs",
"types": "./dist/index.d.ts"
},
"author": "minicx",
"license": "MIT",
"homepage": "https://git.disroot.org/minicx/FlareSolverr.js#README.md",
@ -27,17 +31,22 @@
"cloudflare bypass"
],
"scripts": {
"build:mjs": "tsc -p tsconfig.json",
"build:cjs": "tsc -p tsconfig-cjs.json",
"build": "npm run build:mjs && npm run build:cjs",
"lint": "eslint --fix src/**",
"format": "prettier --write src/**",
"build:mjs": "rm -rf dist/mjs && tsc -p tsconfig.json",
"build:cjs": "rm -rf dist/cjs && tsc -p tsconfig-cjs.json",
"build": "rollup -c",
"lint": "eslint --fix .",
"format": "prettier --write src/** rollup.config.mjs",
"prepublishOnly": "npm run lint && npm run build"
},
"engines": {
"node": ">=16"
},
"devDependencies": {
"@rollup-extras/plugin-clean": "^1.3.6",
"@rollup/plugin-commonjs": "^25.0.4",
"@rollup/plugin-eslint": "^9.0.4",
"@rollup/plugin-terser": "^0.4.3",
"@rollup/plugin-typescript": "^11.1.2",
"@types/mocha": "^10.0.1",
"@types/node": "^16",
"@typescript-eslint/eslint-plugin": "^6.4.0",
@ -50,7 +59,8 @@
"eslint-plugin-unicorn": "^48.0.1",
"mocha": "^10.2.0",
"prettier": "^3.0.2",
"ts-node": "^10.9.1",
"rollup": "^3.28.0",
"tslib": "^2.6.1",
"typescript": "^5.1.6"
}
}

44
rollup.config.mjs Normal file
View File

@ -0,0 +1,44 @@
import terser from '@rollup/plugin-terser';
import ts from '@rollup/plugin-typescript';
import eslint from '@rollup/plugin-eslint';
import clean from '@rollup-extras/plugin-clean';
const output_dir = 'dist';
const rollupConfig = {
input: 'src/index.ts',
output: [
{
dir: output_dir,
format: 'esm',
entryFileNames: '[name].mjs',
},
{
dir: output_dir,
format: 'commonjs',
entryFileNames: '[name].cjs',
},
],
plugins: [
clean('dist'),
eslint({
fix: true,
useEslintrc: true,
}),
ts({
tsconfig: 'tsconfig.json',
}),
terser({
format: {
comments: 'some',
beautify: true,
ecma: 2020,
},
compress: true,
mangle: false,
module: true,
}),
],
};
export default rollupConfig;

View File

@ -1,2 +1 @@
export { FlareSolverr as default } from './FlareSolverr.js';
export { FlareSolverr } from './FlareSolverr.js';

View File

@ -1,7 +0,0 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "CommonJS",
"outDir": "./dist/cjs"
},
}

View File

@ -1,35 +1,30 @@
{
"compilerOptions": {
"target": "ES6",
"module": "ES2022",
"moduleResolution": "Node16",
"rootDir": "./src",
"outDir": "./dist/mjs",
"types": [
"node",
"mocha"
"compilerOptions": {
"rootDir":"src",
"esModuleInterop": true,
"importHelpers": true,
"moduleResolution": "Node16",
"outDir": "./dist",
"types": [
"node",
"mocha"
],
"declaration": true,
"declarationDir": "./dist",
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
},
"ts-node": {
"pretty": true,
"esm": true
},
"include": [
"src",
],
"declaration": true,
"declarationDir": "dist",
"inlineSourceMap":true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
},
"ts-node": {
"pretty": true,
"esm": true
},
"include": [
"src"
],
"exclude": [
"node_modules",
"dist"
]
}
"exclude": [
"node_modules",
"dist"
]
}