diff --git a/.gitignore b/.gitignore index 6986e1e1..c433615e 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,4 @@ node_modules dist *.log .vim -.vscode/ -pure \ No newline at end of file +.vscode/ \ No newline at end of file diff --git a/lib/index.d.mts b/lib/index.d.mts new file mode 100644 index 00000000..6e610401 --- /dev/null +++ b/lib/index.d.mts @@ -0,0 +1 @@ +export * from '../dist'; diff --git a/lib/index.d.ts b/lib/index.d.ts new file mode 100644 index 00000000..6e610401 --- /dev/null +++ b/lib/index.d.ts @@ -0,0 +1 @@ +export * from '../dist'; diff --git a/lib/index.js b/lib/index.js new file mode 100644 index 00000000..c0707d5f --- /dev/null +++ b/lib/index.js @@ -0,0 +1,2 @@ +// eslint-disable-next-line no-undef +module.exports = require('../dist/stripe'); diff --git a/lib/index.mjs b/lib/index.mjs new file mode 100644 index 00000000..29789fc7 --- /dev/null +++ b/lib/index.mjs @@ -0,0 +1 @@ +export * from '../dist/stripe.mjs'; diff --git a/package.json b/package.json index 5de37205..f015556a 100644 --- a/package.json +++ b/package.json @@ -3,18 +3,19 @@ "version": "3.0.8", "description": "Stripe.js loading utility", "repository": "github:stripe/stripe-js", - "main": "dist/stripe.js", - "module": "dist/stripe.mjs", - "jsnext:main": "dist/stripe.mjs", - "types": "dist/index.d.ts", - "typings": "dist/index.d.ts", + "main": "lib/index.js", + "module": "lib/index.mjs", + "jsnext:main": "lib/index.mjs", + "types": "lib/index.d.ts", + "typings": "lib/index.d.ts", "scripts": { "test": "yarn lint && yarn test:unit && yarn test:types && yarn typecheck", "test:unit": "jest", "test:types": "zx ./tests/types/scripts/test.mjs", "lint": "eslint '{src,types}/**/*.{ts,js}' && yarn prettier-check", "typecheck": "tsc", - "build": "yarn clean && yarn rollup -c", + "copy-types": "./scripts/copy-types", + "build": "yarn clean && yarn rollup -c && yarn copy-types", "clean": "rimraf dist", "prepublishOnly": "echo \"\nPlease use ./scripts/publish instead\n\" && exit 1", "prettier": "prettier './**/*.{js,ts,md,html,css}' --write", @@ -30,8 +31,9 @@ "homepage": "https://stripe.com/docs/js", "files": [ "dist", - "src", - "pure" + "lib", + "pure", + "src" ], "engines": { "node": ">=12.16" @@ -56,7 +58,6 @@ "rimraf": "^2.6.2", "rollup": "^1.29.0", "rollup-plugin-babel": "^4.3.3", - "rollup-plugin-dts": "^6.1.0", "rollup-plugin-typescript2": "^0.25.3", "ts-jest": "^24.3.0", "typescript": "^4.1.2", diff --git a/pure/index.d.mts b/pure/index.d.mts new file mode 100644 index 00000000..c740ab68 --- /dev/null +++ b/pure/index.d.mts @@ -0,0 +1 @@ +export * from '../dist/pure'; diff --git a/pure/index.d.ts b/pure/index.d.ts new file mode 100644 index 00000000..c740ab68 --- /dev/null +++ b/pure/index.d.ts @@ -0,0 +1 @@ +export * from '../dist/pure'; diff --git a/pure/index.js b/pure/index.js new file mode 100644 index 00000000..cfbaaa16 --- /dev/null +++ b/pure/index.js @@ -0,0 +1 @@ +module.exports = require('../dist/pure'); diff --git a/pure/index.mjs b/pure/index.mjs new file mode 100644 index 00000000..7c901383 --- /dev/null +++ b/pure/index.mjs @@ -0,0 +1 @@ +export * from '../dist/pure.mjs'; diff --git a/rollup.config.js b/rollup.config.js index 226bddbd..e6e300a7 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,6 +1,5 @@ import babel from 'rollup-plugin-babel'; import ts from 'rollup-plugin-typescript2'; -import {dts} from 'rollup-plugin-dts'; import replace from '@rollup/plugin-replace'; import pkg from './package.json'; @@ -21,33 +20,17 @@ export default [ { input: 'src/index.ts', output: [ - {file: pkg.main, format: 'cjs'}, - {file: pkg.module, format: 'es'}, + {file: 'dist/index.js', format: 'cjs'}, + {file: 'dist/index.mjs', format: 'es'}, ], plugins: PLUGINS, }, - { - input: 'types/index.d.ts', - output: [ - {file: './dist/index.d.ts', format: 'cjs'}, - {file: './dist/index.d.mts', format: 'es'}, - ], - plugins: [dts()], - }, { input: 'src/pure.ts', output: [ - {file: 'pure/index.js', format: 'cjs'}, - {file: 'pure/index.mjs', format: 'es'}, + {file: 'dist/pure.js', format: 'cjs'}, + {file: 'dist/pure.mjs', format: 'es'}, ], plugins: PLUGINS, }, - { - input: 'types/pure.d.ts', - output: [ - {file: './pure/index.d.ts', format: 'cjs'}, - {file: './pure/index.d.mts', format: 'es'}, - ], - plugins: [dts()], - }, ]; diff --git a/scripts/copy-types b/scripts/copy-types new file mode 100755 index 00000000..f6b8b744 --- /dev/null +++ b/scripts/copy-types @@ -0,0 +1,21 @@ +#!/bin/bash + +# Sets the source and destination directories +SRC_DIR="./types" +DEST_DIR="./dist" + +# Finds all .d.ts files in the source directory and copies them +find "$SRC_DIR" -type f -name '*.d.ts' | while read -r src_file; do + # Constructs the destination file path + dest_file="${src_file/$SRC_DIR/$DEST_DIR}" + dest_file_mts="${dest_file/%.d.ts/.d.mts}" + + # Creates the destination directory if it doesn't exist + mkdir -p "$(dirname "$dest_file")" + + # Copys the .d.ts file to the destination directory + cp "$src_file" "$dest_file" + cp "$src_file" "$dest_file_mts" +done + +echo "All .d.ts files have been copied from $SRC_DIR to $DEST_DIR." \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index e189966f..ad25e6be 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1050,7 +1050,7 @@ resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.1.2.tgz#7c6cf998d6d20b914c0a55a91ae928ff25965e72" integrity sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw== -"@jridgewell/sourcemap-codec@^1.4.10", "@jridgewell/sourcemap-codec@^1.4.14", "@jridgewell/sourcemap-codec@^1.4.15": +"@jridgewell/sourcemap-codec@^1.4.10", "@jridgewell/sourcemap-codec@^1.4.14": version "1.4.15" resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz#d7c6e6755c78567a951e04ab52ef0fd26de59f32" integrity sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg== @@ -3774,13 +3774,6 @@ magic-string@^0.25.5: dependencies: sourcemap-codec "^1.4.4" -magic-string@^0.30.4: - version "0.30.7" - resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.30.7.tgz#0cecd0527d473298679da95a2d7aeb8c64048505" - integrity sha512-8vBuFF/I/+OSLRmdf2wwFCJCz+nSn0m6DPvGH1fS/KiQoSaR+sETbov0eIk9KhEKy8CYqIkIAnbohxT/4H0kuA== - dependencies: - "@jridgewell/sourcemap-codec" "^1.4.15" - make-dir@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-2.1.0.tgz#5f0310e18b8be898cc07009295a30ae41e91e6f5" @@ -4668,15 +4661,6 @@ rollup-plugin-babel@^4.3.3: "@babel/helper-module-imports" "^7.0.0" rollup-pluginutils "^2.8.1" -rollup-plugin-dts@^6.1.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/rollup-plugin-dts/-/rollup-plugin-dts-6.1.0.tgz#56e9c5548dac717213c6a4aa9df523faf04f75ae" - integrity sha512-ijSCPICkRMDKDLBK9torss07+8dl9UpY9z1N/zTeA1cIqdzMlpkV3MOOC7zukyvQfDyxa1s3Dl2+DeiP/G6DOw== - dependencies: - magic-string "^0.30.4" - optionalDependencies: - "@babel/code-frame" "^7.22.13" - rollup-plugin-typescript2@^0.25.3: version "0.25.3" resolved "https://registry.yarnpkg.com/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.25.3.tgz#a5fb2f0f85488789334ce540abe6c7011cbdf40f"