From 079302a8618a491a33ac98a50eca2c5f76b61fb9 Mon Sep 17 00:00:00 2001 From: Trim21 Date: Mon, 10 Apr 2023 04:07:59 +0800 Subject: [PATCH] fix build --- package-lock.json | 98 ++++++++++++++++++++++++++++++++++++++- package.json | 7 ++- rollup.config.cjs | 6 +-- src/main/extensions.mjs | 4 +- src/main/helpers.mjs | 2 +- src/main/minio.mjs | 8 ++-- src/main/s3-endpoints.mjs | 2 +- src/main/signing.mjs | 4 +- src/main/transformers.mjs | 6 +-- src/main/xml-parsers.mjs | 7 ++- 10 files changed, 122 insertions(+), 22 deletions(-) diff --git a/package-lock.json b/package-lock.json index 895e06fc9..229634032 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,6 +31,7 @@ "@babel/core": "^7.12.10", "@babel/preset-env": "^7.12.10", "@rollup/plugin-babel": "^6.0.3", + "@rollup/plugin-node-resolve": "^15.0.2", "@rollup/plugin-replace": "^5.0.2", "@rollup/plugin-typescript": "^11.1.0", "@types/lodash": "^4.14.192", @@ -40,6 +41,7 @@ "babelify": "^10.0.0", "browserify": "^16.5.2", "chai": "^4.2.0", + "dotenv": "^16.0.3", "eslint": "^8.37.0", "eslint-config-prettier": "^8.8.0", "eslint-plugin-simple-import-sort": "^10.0.0", @@ -55,6 +57,7 @@ "mocha-steps": "^1.1.0", "nock": "^13.2.2", "prettier": "^2.8.7", + "rollup-plugin-node-externals": "^5.1.2", "source-map-support": "^0.5.13", "split-file": "^2.2.2", "superagent": "^8.0.9", @@ -2187,6 +2190,31 @@ } } }, + "node_modules/@rollup/plugin-node-resolve": { + "version": "15.0.2", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-15.0.2.tgz", + "integrity": "sha512-Y35fRGUjC3FaurG722uhUuG8YHOJRJQbI6/CkbRkdPotSpDj9NtIN85z1zrcyDcCQIW4qp5mgG72U+gJ0TAFEg==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "^5.0.1", + "@types/resolve": "1.20.2", + "deepmerge": "^4.2.2", + "is-builtin-module": "^3.2.1", + "is-module": "^1.0.0", + "resolve": "^1.22.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^2.78.0||^3.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, "node_modules/@rollup/plugin-replace": { "version": "5.0.2", "resolved": "https://registry.npmjs.org/@rollup/plugin-replace/-/plugin-replace-5.0.2.tgz", @@ -2319,6 +2347,12 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/resolve": { + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.20.2.tgz", + "integrity": "sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==", + "dev": true + }, "node_modules/@types/semver": { "version": "7.3.13", "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.3.13.tgz", @@ -3844,6 +3878,18 @@ "integrity": "sha512-571s0T7nZWK6vB67HI5dyUF7wXiNcfaPPPTl6zYCNApANjIvYJTg7hlud/+cJpdAhS7dVzqMLmfhfHR3rAcOjQ==", "license": "MIT" }, + "node_modules/builtin-modules": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.3.0.tgz", + "integrity": "sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==", + "dev": true, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/builtin-status-codes": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz", @@ -4672,6 +4718,15 @@ "dev": true, "license": "MIT" }, + "node_modules/deepmerge": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", + "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/default-compare": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/default-compare/-/default-compare-1.0.0.tgz", @@ -4882,6 +4937,15 @@ "npm": ">=1.2" } }, + "node_modules/dotenv": { + "version": "16.0.3", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz", + "integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==", + "dev": true, + "engines": { + "node": ">=12" + } + }, "node_modules/duplexer2": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz", @@ -8263,6 +8327,21 @@ "dev": true, "license": "MIT" }, + "node_modules/is-builtin-module": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-3.2.1.tgz", + "integrity": "sha512-BSLE3HnV2syZ0FK0iMA/yUGplUeMmNz4AW5fnTunbCIqZi4vG3WjJT9FHMy5D69xmAYBHXQhJdALdpwVxV501A==", + "dev": true, + "dependencies": { + "builtin-modules": "^3.3.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-callable": { "version": "1.2.7", "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", @@ -8406,6 +8485,12 @@ "node": ">=0.10.0" } }, + "node_modules/is-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", + "integrity": "sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==", + "dev": true + }, "node_modules/is-negated-glob": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-negated-glob/-/is-negated-glob-1.0.0.tgz", @@ -11273,7 +11358,6 @@ "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.79.1.tgz", "integrity": "sha512-uKxbd0IhMZOhjAiD5oAFp7BqvkA4Dv47qpOCtaNvng4HBwdbWtdOh8f5nZNuk2rp51PMGk3bzfWu5oayNEuYnw==", "dev": true, - "optional": true, "peer": true, "bin": { "rollup": "dist/bin/rollup" @@ -11285,6 +11369,18 @@ "fsevents": "~2.3.2" } }, + "node_modules/rollup-plugin-node-externals": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/rollup-plugin-node-externals/-/rollup-plugin-node-externals-5.1.2.tgz", + "integrity": "sha512-M32v8yPeVT0dYOYHfd6SNyl0X1xskB15jYFlwUPzIIVpLQ200KVlilbFsoNMUho4SnQuT7Di3s/aLm79bnP48w==", + "dev": true, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^2.60.0 || ^3.0.0" + } + }, "node_modules/run-async": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.1.tgz", diff --git a/package.json b/package.json index a76ac288a..276942aae 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,9 @@ "name": "minio", "version": "7.0.34", "description": "S3 Compatible Cloud Storage client", - "main": "./dist/main/minio.js", + "source": "./src/main/minio.mjs", + "main": "./dist/cjs/minio.cjs", + "module": "./dist/esm/minio.mjs", "scripts": { "format": "prettier -w .", "format-check": "prettier --list-different .", @@ -71,6 +73,7 @@ "@babel/core": "^7.12.10", "@babel/preset-env": "^7.12.10", "@rollup/plugin-babel": "^6.0.3", + "@rollup/plugin-node-resolve": "^15.0.2", "@rollup/plugin-replace": "^5.0.2", "@rollup/plugin-typescript": "^11.1.0", "@types/lodash": "^4.14.192", @@ -80,6 +83,7 @@ "babelify": "^10.0.0", "browserify": "^16.5.2", "chai": "^4.2.0", + "dotenv": "^16.0.3", "eslint": "^8.37.0", "eslint-config-prettier": "^8.8.0", "eslint-plugin-simple-import-sort": "^10.0.0", @@ -95,6 +99,7 @@ "mocha-steps": "^1.1.0", "nock": "^13.2.2", "prettier": "^2.8.7", + "rollup-plugin-node-externals": "^5.1.2", "source-map-support": "^0.5.13", "split-file": "^2.2.2", "superagent": "^8.0.9", diff --git a/rollup.config.cjs b/rollup.config.cjs index a09e5334c..d96834006 100644 --- a/rollup.config.cjs +++ b/rollup.config.cjs @@ -1,16 +1,16 @@ -const path = require('path') - const { getBabelOutputPlugin } = require('@rollup/plugin-babel') const typescript = require('@rollup/plugin-typescript') const replace = require('@rollup/plugin-replace') const externals = require('rollup-plugin-node-externals') +const { nodeResolve } = require('@rollup/plugin-node-resolve') const pkg = require('./package.json') module.exports = { - input: './src/main/minio.mjs', + input: pkg.source, plugins: [ + nodeResolve({ extensions: ['.mjs', '.js', '.ts', '.mts', '.json', '.node'] }), getBabelOutputPlugin({ presets: ['@babel/preset-env'] }), externals({ builtinsPrefix: 'strip' }), typescript({ diff --git a/src/main/extensions.mjs b/src/main/extensions.mjs index 13d1c2649..27a4e597b 100644 --- a/src/main/extensions.mjs +++ b/src/main/extensions.mjs @@ -16,8 +16,8 @@ import Stream from 'stream' -import * as errors from './errors.js' -import { isBoolean, isNumber, isString, isValidBucketName, isValidPrefix, pipesetup, uriEscape } from './helpers.js' +import * as errors from './errors' +import { isBoolean, isNumber, isString, isValidBucketName, isValidPrefix, pipesetup, uriEscape } from './helpers' import * as transformers from './transformers' export default class extensions { diff --git a/src/main/helpers.mjs b/src/main/helpers.mjs index e41376b24..aa56cbc75 100644 --- a/src/main/helpers.mjs +++ b/src/main/helpers.mjs @@ -25,7 +25,7 @@ import path from 'path' import querystring from 'query-string' import stream from 'stream' -import * as errors from './errors.js' +import * as errors from './errors' const fxp = new XMLParser() diff --git a/src/main/minio.mjs b/src/main/minio.mjs index cccd02dca..69024d119 100644 --- a/src/main/minio.mjs +++ b/src/main/minio.mjs @@ -29,7 +29,7 @@ import Xml from 'xml' import xml2js from 'xml2js' import CredentialProvider from './CredentialProvider' -import * as errors from './errors.js' +import * as errors from './errors' import extensions from './extensions' import { calculateEvenSplits, @@ -71,11 +71,11 @@ import { toSha256, uriEscape, uriResourceEscape, -} from './helpers.js' +} from './helpers' import { NotificationConfig, NotificationPoller } from './notification' import ObjectUploader from './object-uploader' -import { getS3Endpoint } from './s3-endpoints.js' -import { postPresignSignatureV4, presignSignatureV4, signV4 } from './signing.js' +import { getS3Endpoint } from './s3-endpoints' +import { postPresignSignatureV4, presignSignatureV4, signV4 } from './signing' import * as transformers from './transformers' import { parseSelectObjectContentResponse } from './xml-parsers' diff --git a/src/main/s3-endpoints.mjs b/src/main/s3-endpoints.mjs index d367a880b..9c84e2789 100644 --- a/src/main/s3-endpoints.mjs +++ b/src/main/s3-endpoints.mjs @@ -14,7 +14,7 @@ * limitations under the License. */ -import { isString } from './helpers.js' +import { isString } from './helpers' // List of currently supported endpoints. let awsS3Endpoint = { diff --git a/src/main/signing.mjs b/src/main/signing.mjs index 3a7366172..c4bd38b6c 100644 --- a/src/main/signing.mjs +++ b/src/main/signing.mjs @@ -17,8 +17,8 @@ import Crypto from 'crypto' import _ from 'lodash' -import * as errors from './errors.js' -import { getScope, isArray, isNumber, isObject, isString, makeDateLong, makeDateShort, uriEscape } from './helpers.js' +import * as errors from './errors' +import { getScope, isArray, isNumber, isObject, isString, makeDateLong, makeDateShort, uriEscape } from './helpers' const signV4Algorithm = 'AWS4-HMAC-SHA256' diff --git a/src/main/transformers.mjs b/src/main/transformers.mjs index d6caaf6ef..a3816dff2 100644 --- a/src/main/transformers.mjs +++ b/src/main/transformers.mjs @@ -19,9 +19,9 @@ import JSONParser from 'json-stream' import * as _ from 'lodash' import Through2 from 'through2' -import * as errors from './errors.js' -import { isFunction } from './helpers.js' -import * as xmlParsers from './xml-parsers.js' +import * as errors from './errors' +import { isFunction } from './helpers' +import * as xmlParsers from './xml-parsers' // getConcater returns a stream that concatenates the input and emits // the concatenated output when 'end' has reached. If an optional diff --git a/src/main/xml-parsers.mjs b/src/main/xml-parsers.mjs index d668e2034..67980fc27 100644 --- a/src/main/xml-parsers.mjs +++ b/src/main/xml-parsers.mjs @@ -13,13 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { XMLParser } from 'fast-xml-parser' - -const fxp = new XMLParser() import crc32 from 'buffer-crc32' +import { XMLParser } from 'fast-xml-parser' import _ from 'lodash' -import * as errors from './errors.mts' +import * as errors from './errors' import { isObject, parseXml, @@ -31,6 +29,7 @@ import { toArray, } from './helpers' // Parse XML and return information as Javascript types +const fxp = new XMLParser() // parse error XML response export function parseError(xml, headerInfo) {