Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate from Rollup to preconstruct for bundling #1933

Open
wants to merge 6 commits into
base: yarn-to-pnpm
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,6 @@ const getPresets = () => {
targets: { node: 'current' },
modules: 'commonjs',
}
case 'rollup':
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed anymore.

return {
targets: {
browsers: ['last 2 versions'],
node: 'current',
},
modules: false,
}
case 'production':
return {
targets: {
Expand Down
30 changes: 17 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
"postinstall": "./scripts/postinstall.sh",
"clean": "rm -rf coverage; manypkg exec rimraf lib dist node_modules; rm -rf node_modules",
"commit": "git-cz",
"build": "pnpm --recursive run build",
"build": "pnpm preconstruct build",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This builds what's configured below.

"check-gh-auth-token": "if [[ -z \"${GITHUB_AUTH}\" ]]; then echo \"Need to set GITHUB_AUTH\" && exit 1; fi",
"build:typings": "NODE_ENV=production pnpm --recursive run build:typings",
"lint": "jest --projects jest.eslint.config.js jest.flow.config.js",
"lint:js": "jest --config jest.eslint.config.js",
"test": "cross-env NODE_ENV=development jest --config jest.test.config.js",
Expand Down Expand Up @@ -74,7 +73,7 @@
"@commitlint/cli": "19.7.1",
"@commitlint/config-conventional": "12.1.4",
"@manypkg/cli": "0.23.0",
"@rollup/plugin-alias": "5.1.1",
"@preconstruct/cli": "2.8.11",
"@types/jest": "26.0.24",
"@types/node": "10.17.60",
"@types/node-fetch": "2.5.12",
Expand Down Expand Up @@ -119,19 +118,24 @@
"prettier": "2.4.1",
"resolve": "1.22.10",
"rimraf": "3.0.2",
"rollup": "4.34.9",
"rollup-plugin-babel": "4.4.0",
"rollup-plugin-commonjs": "10.1.0",
"rollup-plugin-includepaths": "0.2.4",
"rollup-plugin-json": "4.0.0",
"rollup-plugin-node-globals": "1.4.0",
"rollup-plugin-node-resolve": "5.2.0",
"rollup-plugin-replace": "2.2.0",
"rollup-plugin-uglify": "6.0.4",
"rollup-watch": "4.3.1",
"streamtest": "2.0.0",
"ts-jest": "26.5.6",
"tsconfig-replace-paths": "0.0.14",
"typescript": "4.5.2"
},
"preconstruct": {
"packages": [
"packages/api-request-builder",
"packages/http-user-agent",
"packages/sdk-auth",
"packages/sdk-client",
"packages/sdk-middleware-auth",
"packages/sdk-middleware-correlation-id",
"packages/sdk-middleware-http",
"packages/sdk-middleware-logger",
"packages/sdk-middleware-queue",
"packages/sdk-middleware-user-agent",
"packages/sync-actions"
Comment on lines +128 to +138
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are all packages which are configured as SDKs and were prior built with Rollup.

]
}
}
15 changes: 10 additions & 5 deletions packages/api-request-builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,15 @@
"bugs": "https://github.com/commercetools/nodejs/issues",
"license": "MIT",
"author": "Nicola Molinari <[email protected]> (https://github.com/emmenko)",
"main": "dist/api-request-builder.cjs.js",
"module": "dist/api-request-builder.es.js",
"browser": "dist/api-request-builder.umd.js",
"main": "dist/commercetools-api-request-builder.cjs.js",
"module": "dist/commercetools-api-request-builder.esm.js",
"umd:main": "dist/commercetools-api-request-builder.umd.min.js",
"preconstruct": {
"entrypoints": [
"./index.js"
],
"umdName": "commercetoolsApiRequestBuilder"
},
Comment on lines +22 to +30
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naming change is transparent to users it follows the preconstruct and general community standards.

"repository": {
"type": "git",
"url": "https://github.com/commercetools/nodejs.git"
Expand All @@ -30,7 +36,6 @@
"dist"
],
"scripts": {
"build": "pnpm build:bundles",
"build:bundles": "cross-env NODE_ENV=production rollup -c ../../rollup.config.js -n CommercetoolsApiRequestBuilder -i ./src/index.js"
"build": "exit 0;"
}
}
23 changes: 15 additions & 8 deletions packages/http-user-agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,20 @@
"bugs": "https://github.com/commercetools/nodejs/issues",
"license": "MIT",
"author": "Nicola Molinari <[email protected]> (https://github.com/emmenko)",
"main": "dist/http-user-agent.cjs.js",
"module": "dist/http-user-agent.es.js",
"browser": "dist/http-user-agent.umd.js",
"typings": "./dist/typings/index.d.ts",
"types": "./dist/typings/index.d.ts",
"main": "dist/commercetools-http-user-agent.cjs.js",
"module": "dist/commercetools-http-user-agent.esm.js",
"browser": {
"./dist/commercetools-http-user-agent.cjs.js": "./dist/commercetools-http-user-agent.browser.cjs.js",
"./dist/commercetools-http-user-agent.esm.js": "./dist/commercetools-http-user-agent.browser.esm.js"
},
"typings": "./dist/commercetools-http-user-agent.cjs.d.ts",
"types": "./dist/commercetools-http-user-agent.cjs.d.ts",
"preconstruct": {
"entrypoints": [
"./index.ts"
],
"umdName": "commercetoolsHttpUserAgent"
},
"repository": {
"type": "git",
"url": "https://github.com/commercetools/nodejs.git"
Expand All @@ -31,8 +40,6 @@
],
"scripts": {
"prebuild": "rimraf dist/**",
"build": "pnpm build:bundles && pnpm build:typings",
"build:bundles": "cross-env NODE_ENV=production rollup -c ../../rollup.config.js -n CommercetoolsHttpUserAgent -i ./src/index.ts",
"build:typings": "tsc -p tsconfig.declarations.json --emitDeclarationOnly --declarationDir dist/typings"
"build": "exit 0;"
}
}
12 changes: 6 additions & 6 deletions packages/http-user-agent/src/create-user-agent.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
type HttpUserAgentOptions = {
name: string
version?: string
libraryName?: string
libraryVersion?: string
contactUrl?: string
contactEmail?: string
name: string;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise this is a syntax error.

version?: string;
libraryName?: string;
libraryVersion?: string;
contactUrl?: string;
contactEmail?: string;
}

/*
Expand Down
15 changes: 10 additions & 5 deletions packages/sdk-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@
"bugs": "https://github.com/commercetools/nodejs/issues",
"license": "MIT",
"author": "Jan Juna <[email protected]> (https://github.com/junajan)",
"main": "dist/sdk-auth.cjs.js",
"module": "dist/sdk-auth.es.js",
"browser": "dist/sdk-auth.umd.js",
"main": "dist/commercetools-sdk-auth.cjs.js",
"module": "dist/commercetools-sdk-auth.esm.js",
"umd:min": "dist/commercetools-sdk-auth.umd.js",
"preconstruct": {
"entrypoints": [
"./index.js"
],
"umdName": "commercetoolsSdkAuth"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just the function name in the UMD bundle.

},
"repository": {
"type": "git",
"url": "https://github.com/commercetools/nodejs.git"
Expand All @@ -30,8 +36,7 @@
],
"scripts": {
"prebuild": "rimraf dist/**",
"build": "pnpm build:bundles",
"build:bundles": "cross-env NODE_ENV=production rollup -c ../../rollup.config.js -n CommercetoolsSdkAuth -i ./src/index.js"
"build": "exit 0;"
},
"dependencies": {
"@commercetools/sdk-middleware-http": "^8.0.0",
Expand Down
15 changes: 10 additions & 5 deletions packages/sdk-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@
"bugs": "https://github.com/commercetools/nodejs/issues",
"license": "MIT",
"author": "Nicola Molinari <[email protected]> (https://github.com/emmenko)",
"main": "dist/sdk-client.cjs.js",
"module": "dist/sdk-client.es.js",
"browser": "dist/sdk-client.umd.js",
"main": "dist/commercetools-sdk-client.cjs.js",
"module": "dist/commercetools-sdk-client.esm.js",
"umd:min": "dist/commercetools-sdk-client.umd.js",
"preconstruct": {
"entrypoints": [
"./index.js"
],
"umdName": "commercetoolsSdkClient"
},
"repository": {
"type": "git",
"url": "https://github.com/commercetools/nodejs.git"
Expand All @@ -30,7 +36,6 @@
],
"scripts": {
"prebuild": "rimraf dist/**",
"build": "pnpm build:bundles",
"build:bundles": "cross-env NODE_ENV=production rollup -c ../../rollup.config.js -n CommercetoolsSdkClient -i ./src/index.js"
"build": "exit 0;"
}
}
16 changes: 11 additions & 5 deletions packages/sdk-middleware-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,15 @@
"bugs": "https://github.com/commercetools/nodejs/issues",
"license": "MIT",
"author": "Nicola Molinari <[email protected]> (https://github.com/emmenko)",
"main": "dist/sdk-middleware-auth.cjs.js",
"module": "dist/sdk-middleware-auth.es.js",
"browser": "dist/sdk-middleware-auth.umd.js",
"main": "dist/commercetools-sdk-middleware-auth.cjs.js",
"module": "dist/commercetools-sdk-middleware-auth.esm.js",
"umd:min": "dist/commercetools-sdk-middleware-auth.umd.js",
"preconstruct": {
"entrypoints": [
"./index.js"
],
"umdName": "commercetoolsSdkMiddlewareAuth"
},
"repository": {
"type": "git",
"url": "https://github.com/commercetools/nodejs.git"
Expand All @@ -31,10 +37,10 @@
],
"scripts": {
"prebuild": "rimraf dist/**",
"build": "pnpm build:bundles",
"build:bundles": "cross-env NODE_ENV=production rollup -c ../../rollup.config.js -n CommercetoolsSdkMiddlewareAuth -i ./src/index.js"
"build": "exit 0;"
},
"dependencies": {
"@commercetools/sdk-middleware-http": "^8.0.0",
"node-fetch": "^2.6.7"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk-middleware-auth/src/base-auth-flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type {
AuthMiddlewareOptions,
executeRequestOptions,
} from 'types/sdk'
import { NetworkError } from '../../sdk-middleware-http/src/errors'
import { errors } from '@commercetools/sdk-middleware-http'
import { buildRequestForRefreshTokenFlow } from './build-requests'

function mergeAuthHeader(
Expand Down Expand Up @@ -217,7 +217,7 @@ function executeRequest({
typeof response.reject === 'function' &&
error?.type === 'aborted'
) {
const _error = new NetworkError(error.message, {
const _error = new errors.NetworkError(error.message, {
type: error.type,
request,
})
Expand Down
15 changes: 10 additions & 5 deletions packages/sdk-middleware-correlation-id/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,15 @@
"bugs": "https://github.com/commercetools/nodejs/issues",
"license": "MIT",
"author": "Tobias Deekens <[email protected]> (https://github.com/tdeekens)",
"main": "dist/sdk-middleware-correlation-id.cjs.js",
"module": "dist/sdk-middleware-correlation-id.es.js",
"browser": "dist/sdk-middleware-correlation-id.umd.js",
"main": "dist/commercetools-sdk-middleware-correlation-id.cjs.js",
"module": "dist/commercetools-sdk-middleware-correlation-id.esm.js",
"umd:min": "dist/commercetools-sdk-middleware-correlation-id.umd.js",
"preconstruct": {
"entrypoints": [
"./index.js"
],
"umdName": "commercetoolsSdkMiddlewareCorrelationId"
},
"repository": {
"type": "git",
"url": "https://github.com/commercetools/nodejs.git"
Expand All @@ -31,7 +37,6 @@
],
"scripts": {
"prebuild": "rimraf dist/**",
"build": "pnpm build:bundles",
"build:bundles": "cross-env NODE_ENV=production rollup -c ../../rollup.config.js -n CommercetoolsSdkMiddlewareCorrelationId -i ./src/index.js"
"build": "exit 0;"
}
}
15 changes: 10 additions & 5 deletions packages/sdk-middleware-http/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@
"bugs": "https://github.com/commercetools/nodejs/issues",
"license": "MIT",
"author": "Nicola Molinari <[email protected]> (https://github.com/emmenko)",
"main": "dist/sdk-middleware-http.cjs.js",
"module": "dist/sdk-middleware-http.es.js",
"browser": "dist/sdk-middleware-http.umd.js",
"main": "dist/commercetools-sdk-middleware-http.cjs.js",
"module": "dist/commercetools-sdk-middleware-http.esm.js",
"umd:min": "dist/commercetools-sdk-middleware-http.umd.js",
"preconstruct": {
"entrypoints": [
"./index.js"
],
"umdName": "commercetoolsSdkMiddlewareHttp"
},
"repository": {
"type": "git",
"url": "https://github.com/commercetools/nodejs.git"
Expand All @@ -30,8 +36,7 @@
],
"scripts": {
"prebuild": "rimraf dist/**",
"build": "pnpm build:bundles",
"build:bundles": "cross-env NODE_ENV=production rollup -c ../../rollup.config.js -n CommercetoolsSdkMiddlewareHttp -i ./src/index.js"
"build": "exit 0;"
},
"devDependencies": {
"abort-controller": "3.0.0",
Expand Down
15 changes: 10 additions & 5 deletions packages/sdk-middleware-logger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@
"bugs": "https://github.com/commercetools/nodejs/issues",
"license": "MIT",
"author": "Nicola Molinari <[email protected]> (https://github.com/emmenko)",
"main": "dist/sdk-middleware-logger.cjs.js",
"module": "dist/sdk-middleware-logger.es.js",
"browser": "dist/sdk-middleware-logger.umd.js",
"main": "dist/commercetools-sdk-middleware-logger.cjs.js",
"module": "dist/commercetools-sdk-middleware-logger.esm.js",
"umd:min": "dist/commercetools-sdk-middleware-logger.umd.js",
"preconstruct": {
"entrypoints": [
"./index.js"
],
"umdName": "commercetoolsSdkMiddlewareLogger"
},
"repository": {
"type": "git",
"url": "https://github.com/commercetools/nodejs.git"
Expand All @@ -30,7 +36,6 @@
],
"scripts": {
"prebuild": "rimraf dist/**",
"build": "pnpm build:bundles",
"build:bundles": "cross-env NODE_ENV=production rollup -c ../../rollup.config.js -n CommercetoolsSdkMiddlewareLogger -i ./src/index.js"
"build": "exit 0;"
}
}
15 changes: 10 additions & 5 deletions packages/sdk-middleware-queue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@
"bugs": "https://github.com/commercetools/nodejs/issues",
"license": "MIT",
"author": "Nicola Molinari <[email protected]> (https://github.com/emmenko)",
"main": "dist/sdk-middleware-queue.cjs.js",
"module": "dist/sdk-middleware-queue.es.js",
"browser": "dist/sdk-middleware-queue.umd.js",
"main": "dist/commercetools-sdk-middleware-queue.cjs.js",
"module": "dist/commercetools-sdk-middleware-queue.esm.js",
"umd:min": "dist/commercetools-sdk-middleware-queue.umd.js",
"preconstruct": {
"entrypoints": [
"./index.js"
],
"umdName": "commercetoolsSdkMiddlewareQueue"
},
"repository": {
"type": "git",
"url": "https://github.com/commercetools/nodejs.git"
Expand All @@ -30,7 +36,6 @@
],
"scripts": {
"prebuild": "rimraf dist/**",
"build": "pnpm build:bundles",
"build:bundles": "cross-env NODE_ENV=production rollup -c ../../rollup.config.js -n CommercetoolsSdkMiddlewareQueue -i ./src/index.js"
"build": "exit 0;"
}
}
Loading