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

refactor: turn into dual node package with additional browser bundle #2169

Merged
merged 84 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from 79 commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
bf547b4
refactor: turn into dual node package with additional browser bundle
axe312ger Feb 22, 2024
bba3862
build: remove unused renamer dependency
axe312ger Feb 22, 2024
b2f5be5
prettier
mgoudy91 Feb 22, 2024
a2c58c9
build(deps-dev): bump express from 4.18.2 to 4.18.3 (#2174)
dependabot[bot] Mar 1, 2024
4b8a5f7
chore: unown package files [] (#2165)
ghepting Mar 1, 2024
d7bb894
build(deps-dev): bump typedoc from 0.25.9 to 0.25.10 (#2176)
dependabot[bot] Mar 4, 2024
7304583
build(deps): bump type-fest from 4.10.3 to 4.11.0 (#2177)
dependabot[bot] Mar 5, 2024
5ba3ef6
build(deps): bump @contentful/rich-text-types from 16.3.4 to 16.3.5 (…
dependabot[bot] Mar 5, 2024
414e63d
build(deps): bump type-fest from 4.11.0 to 4.11.1 (#2179)
dependabot[bot] Mar 6, 2024
289bac7
feat: github migration [EXT-5014]
david-shibley-contentful Mar 6, 2024
4c7fefc
feat: github migration [EXT-5014]
david-shibley-contentful Mar 6, 2024
5946e13
adding vault context
david-shibley-contentful Mar 6, 2024
5a9827f
fix: [] - fix build
ContentfulCormac Mar 7, 2024
f2073d5
build(deps-dev): bump typedoc from 0.25.10 to 0.25.11 (#2182)
dependabot[bot] Mar 7, 2024
e0288ee
build(deps-dev): bump typedoc from 0.25.11 to 0.25.12 (#2183)
dependabot[bot] Mar 11, 2024
2ebc1df
build(deps): bump type-fest from 4.11.1 to 4.12.0 (#2184)
dependabot[bot] Mar 11, 2024
0110e51
wip: use rollup to bundle
axe312ger Mar 20, 2024
f8d0670
refactor: improve rollup integration
axe312ger Mar 25, 2024
2a7748d
WIP - replace Jest with Vitest
axe312ger Mar 25, 2024
bf44d13
refactor: fix all integration tests and clean up
axe312ger Mar 26, 2024
551ae23
build: fix rollup browser bundle
axe312ger Apr 8, 2024
e938f5c
Merge branch 'master' into refactor/modern-esm-support
axe312ger Apr 8, 2024
53f3411
build: fix rollup process resolve
axe312ger Apr 8, 2024
2c070c8
build: readd tsd
axe312ger Apr 8, 2024
97fa9ff
build: remove bundle size check again from postbuild to avoid issues …
axe312ger Apr 8, 2024
2ca610e
ci: move to latest node v18 to avoid warnings while installing
axe312ger Apr 8, 2024
e680dd5
build: adjust for new structure of contentful-sdk-core
axe312ger Apr 8, 2024
15a90e2
fix: to ensure we are ECMA2018 compatible with browser bundle
axe312ger Apr 9, 2024
df796b7
test: fix mocks of sdk-core
axe312ger May 10, 2024
debc408
build: use rollup to inject plugin version into ESM export
axe312ger May 10, 2024
760eb56
build: ensure types are defined in the exports in package.json
axe312ger May 10, 2024
3d04599
deps: remove obsolete dependencies
axe312ger May 27, 2024
f80be0b
refactor: make it work with react-native and other bundlers
axe312ger May 27, 2024
24da50c
build: update to latest sdk-core version
axe312ger May 28, 2024
0aba101
build: update to latest sdk-core version
axe312ger May 28, 2024
d377c75
build: add missing fast-copy dev dependency
axe312ger May 28, 2024
c2573fc
build: minor and patch updates of dependencies
axe312ger May 28, 2024
e6b3b14
Revert "build: minor and patch updates of dependencies"
axe312ger May 28, 2024
d1e1ddc
build: increase browser bundle size limit - sorry - updates forced me
axe312ger May 28, 2024
162d114
build: v11.0.0-alpha.8
axe312ger May 28, 2024
d8fe36c
Merge branch 'master' into refactor/modern-esm-support
axe312ger Jun 19, 2024
1433009
build: remove local verdaccio traces
axe312ger Jun 19, 2024
28383cd
Merge branch 'master' into refactor/modern-esm-support
axe312ger Jul 12, 2024
b50017c
test: ensure output-integration browser test is working again and usi…
axe312ger Jul 13, 2024
b3c5211
build: upgrade CTF source maps to latest
axe312ger Jul 13, 2024
24e8d60
build: load rich-text-types for now from npm
axe312ger Jul 13, 2024
b049ee1
build: update rollup and typescript dependencies to latest
axe312ger Jul 13, 2024
6a7a637
build: upgrade to vitest v2
axe312ger Jul 13, 2024
01da5cc
test: update broken integration tests from git merge
axe312ger Jul 13, 2024
e2229ad
fix: reset version number to valid semver
axe312ger Jul 13, 2024
e25062b
chore: no need to hard code the bin directory for tsd
axe312ger Jul 13, 2024
e6f0e86
chore: test types on push as its very fast and avoids useless waiting…
axe312ger Jul 13, 2024
ad7dc99
Merge branch 'master' into refactor/modern-esm-support
axe312ger Jul 18, 2024
ece678c
test: slightly increase bundle sizes
axe312ger Jul 18, 2024
d479c5f
Merge branch 'master' into refactor/modern-esm-support
mgoudy91 Jul 18, 2024
69c54a5
docs: update README.md to include information about the new ESM support
axe312ger Aug 2, 2024
959298c
docs: update TOC and fix format of tables in README
axe312ger Aug 2, 2024
0b16678
docs: update import syntax in readme
axe312ger Aug 2, 2024
e5b9592
Merge branch 'master' into refactor/modern-esm-support
axe312ger Aug 2, 2024
48520b1
build: npm dedupe
axe312ger Aug 2, 2024
f649101
Merge branch 'master' into refactor/modern-esm-support
mgoudy91 Aug 5, 2024
e904c1a
fix: bundle size
mgoudy91 Aug 5, 2024
0d98b7c
fix: plock
mgoudy91 Aug 5, 2024
c535d21
fix: remove bundle size
mgoudy91 Aug 6, 2024
8845745
Merge branch 'master' into refactor/modern-esm-support
mgoudy91 Sep 9, 2024
af82ae2
fix: tsc "Right operand of ?? is unreachable because the left operand…
mgoudy91 Sep 9, 2024
552d2d6
fix: regen plock
mgoudy91 Sep 9, 2024
3f6fd96
test: fix query params
mgoudy91 Sep 9, 2024
c75db4f
fix: bump size
mgoudy91 Sep 9, 2024
c6c61dd
Merge branch 'master' into refactor/modern-esm-support
mgoudy91 Sep 10, 2024
81411c8
test: test updates
mgoudy91 Sep 10, 2024
829200d
BREAKING CHANGE: adding dry run flag, BC commit tag to force major (#…
mgoudy91 Sep 10, 2024
c133084
build(deps-dev): bump express in the dev-dependencies group (#2326)
dependabot[bot] Sep 11, 2024
201c5ab
Merge branch 'master' into refactor/modern-esm-support
axe312ger Sep 11, 2024
3afc352
build(deps-dev): bump express in the dev-dependencies group (#2327)
dependabot[bot] Sep 12, 2024
7db6ac6
Merge branch 'master' into refactor/modern-esm-support
mgoudy91 Sep 12, 2024
52f5dfc
build(deps): bump the production-dependencies group with 2 updates (#…
dependabot[bot] Sep 17, 2024
e03c62a
build(deps-dev): bump babel-loader in the dev-dependencies group (#2329)
dependabot[bot] Sep 17, 2024
3690d2a
Merge remote-tracking branch 'origin' into refactor/modern-esm-support
mgoudy91 Sep 17, 2024
7f7ca93
build(deps-dev): bump nodemon in the dev-dependencies group (#2330)
dependabot[bot] Sep 18, 2024
a813188
build(deps-dev): bump nodemon in the dev-dependencies group (#2330)
dependabot[bot] Sep 18, 2024
5d5415a
chore: rm dry-run flag
mgoudy91 Sep 19, 2024
983046d
Merge branch 'master' into refactor/modern-esm-support
mgoudy91 Sep 19, 2024
067306e
Merge branch 'master' into refactor/modern-esm-support
mgoudy91 Sep 19, 2024
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: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ orbs:
jobs:
lint:
docker:
- image: cimg/node:18.19-browsers
- image: 'cimg/node:18.20.1-browsers'
steps:
- checkout
- vault/get-secrets: # Loads vault secrets
Expand All @@ -28,7 +28,7 @@ jobs:
steps:
- checkout
- node/install:
node-version: '18.17'
node-version: '18.20.1'
- vault/get-secrets: # Loads vault secrets
template-preset: 'packages-read'
- run: echo "//npm.pkg.github.com/:_authToken=${GITHUB_PACKAGES_READ_TOKEN}" > ~/.npmrc
Expand All @@ -42,7 +42,7 @@ jobs:
steps:
- checkout
- node/install:
node-version: '18.17'
node-version: '18.20.1'
- vault/get-secrets: # Loads vault secrets
template-preset: 'packages-read'
- run: echo "//npm.pkg.github.com/:_authToken=${GITHUB_PACKAGES_READ_TOKEN}" > ~/.npmrc
Expand All @@ -52,7 +52,7 @@ jobs:

release:
docker:
- image: cimg/node:18.19-browsers
- image: 'cimg/node:18.20.1-browsers'
steps:
- checkout
- browser-tools/install-chrome
Expand Down
3 changes: 2 additions & 1 deletion .eslintrc.js → .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
parser: '@typescript-eslint/parser',
plugins: ['standard', 'promise'],
env: {
jest: true,
node: true,
},
globals: {
Expand All @@ -12,6 +12,7 @@ module.exports = {
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
'plugin:vitest-globals/recommended',
],
ignorePatterns: ['**/test/output-integration/**', '**/webpack.config.js'],
rules: {
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
dist
gh-pages
test/output-integration/browser/public/contentful*.js

# Esdoc dirs
out
Expand Down
2 changes: 2 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
npm run lint
npm run prettier:check
1 change: 1 addition & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npm run test:prepush
137 changes: 83 additions & 54 deletions README.md

Large diffs are not rendered by default.

12 changes: 0 additions & 12 deletions jest.config.js

This file was deleted.

14 changes: 9 additions & 5 deletions lib/contentful.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
* with access to the Contentful Content Delivery API.
*/

import type { AxiosAdapter, AxiosRequestConfig, AxiosResponse } from 'axios'
import axios from 'axios'
import type { AxiosAdapter, AxiosRequestConfig, AxiosResponse } from 'axios'

import { createHttpClient, getUserAgentHeader } from 'contentful-sdk-core'
import { createGlobalOptions } from './create-global-options'
import { makeClient } from './make-client'
import { ContentfulClientApi } from './types'
import { validateRemoveUnresolvedParam, validateResolveLinksParam } from './utils/validate-params'
import { createGlobalOptions } from './create-global-options.js'
import { makeClient } from './make-client.js'
import {
validateRemoveUnresolvedParam,
validateResolveLinksParam,
} from './utils/validate-params.js'
import type { ContentfulClientApi } from './types/client.js'

/**
* @category Client
Expand Down
32 changes: 16 additions & 16 deletions lib/create-contentful-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,38 @@
import { encodeCPAResponse } from '@contentful/content-source-maps'
import { AxiosInstance, createRequestConfig, errorHandler } from 'contentful-sdk-core'
import { CreateClientParams } from './contentful'
import { GetGlobalOptions } from './create-global-options'
import pagedSync from './paged-sync'
import {
import { GetGlobalOptions } from './create-global-options.js'
import pagedSync from './paged-sync.js'
import type {
Asset,
AssetCollection,
AssetKey,
ContentfulClientApi,
ContentType,
ContentTypeCollection,
EntryCollection,
EntrySkeletonType,
LocaleCode,
LocaleCollection,
Space,
SyncOptions,
SyncQuery,
Tag,
TagCollection,
} from './types'
import { ChainOptions, ModifiersFromOptions } from './utils/client-helpers'
import normalizeSearchParameters from './utils/normalize-search-parameters'
import normalizeSelect from './utils/normalize-select'
EntryCollection,
SyncQuery,
SyncOptions,
EntrySkeletonType,
LocaleCode,
} from './types/index.js'
import normalizeSearchParameters from './utils/normalize-search-parameters.js'
import normalizeSelect from './utils/normalize-select.js'
import resolveCircular from './utils/resolve-circular.js'
import getQuerySelectionSet from './utils/query-selection-set'
import resolveCircular from './utils/resolve-circular'
import validateTimestamp from './utils/validate-timestamp.js'
import { ChainOptions, ModifiersFromOptions } from './utils/client-helpers.js'
import {
checkIncludeContentSourceMapsParamIsAllowed,
validateLocaleParam,
validateRemoveUnresolvedParam,
validateResolveLinksParam,
} from './utils/validate-params'
import validateSearchParameters from './utils/validate-search-parameters'
import validateTimestamp from './utils/validate-timestamp'

const ASSET_KEY_MAX_LIFETIME = 48 * 60 * 60

Expand Down Expand Up @@ -275,7 +275,7 @@ export default function createContentfulApi<OptionType extends ChainOptions>(
})

return resolveCircular(entries, {
resolveLinks: !withoutLinkResolution ?? true,
resolveLinks: !withoutLinkResolution,
removeUnresolved: withoutUnresolvableLinks ?? false,
})
} catch (error) {
Expand Down Expand Up @@ -462,7 +462,7 @@ export default function createContentfulApi<OptionType extends ChainOptions>(
const { withoutLinkResolution, withoutUnresolvableLinks } = options

return resolveCircular(data, {
resolveLinks: !withoutLinkResolution ?? true,
resolveLinks: !withoutLinkResolution,
removeUnresolved: withoutUnresolvableLinks ?? false,
})
}
Expand Down
12 changes: 6 additions & 6 deletions lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export * from './contentful'
export * from './create-global-options'
export * from './mixins/stringify-safe'
export * from './utils/normalize-select'
export * from './utils/resolve-circular'
export * from './contentful.js'
export * from './create-global-options.js'
export * from './mixins/stringify-safe.js'
export * from './utils/normalize-select.js'
export * from './utils/resolve-circular.js'

export * from './types'
export * from './types/index.js'
6 changes: 3 additions & 3 deletions lib/make-client.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import createContentfulApi, { CreateContentfulApiParams } from './create-contentful-api'
import createContentfulApi, { CreateContentfulApiParams } from './create-contentful-api.js'
import {
ChainOptions,
DefaultChainOption,
ChainOption,
ModifiersFromOptions,
} from './utils/client-helpers'
import { ContentfulClientApi } from './types'
} from './utils/client-helpers.js'
import type { ContentfulClientApi } from './types/index.js'

function create<OptionsType extends ChainOptions>(
{ http, getGlobalOptions }: CreateContentfulApiParams,
Expand Down
8 changes: 4 additions & 4 deletions lib/paged-sync.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import resolveResponse from 'contentful-resolve-response'
import { AxiosInstance, createRequestConfig, freezeSys, toPlainObject } from 'contentful-sdk-core'
import mixinStringifySafe from './mixins/stringify-safe'
import {
import mixinStringifySafe from './mixins/stringify-safe.js'
import type {
SyncPageQuery,
SyncResponse,
SyncPageResponse,
Expand All @@ -11,8 +11,8 @@ import {
SyncQuery,
LocaleCode,
EntrySkeletonType,
} from './types'
import { ChainOptions, ModifiersFromOptions } from './utils/client-helpers'
} from './types/index.js'
import { ChainOptions, ModifiersFromOptions } from './utils/client-helpers.js'

/**
* Retrieves all the available pages for a sync operation
Expand Down
30 changes: 15 additions & 15 deletions lib/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
export * from './asset'
export * from './asset-key'
export { AddChainModifier, ChainModifiers, ContentfulClientApi } from './client'
export * from './collection'
export * from './content-type'
export * from './entry'
export * from './link'
export * from './locale'
export * from './metadata'
export * from './query'
export * from './resource-link'
export * from './space'
export * from './sync'
export * from './sys'
export * from './tag'
export * from './asset.js'
export * from './asset-key.js'
export { AddChainModifier, ChainModifiers, ContentfulClientApi } from './client.js'
export * from './collection.js'
export * from './content-type.js'
export * from './entry.js'
export * from './link.js'
export * from './locale.js'
export * from './metadata.js'
export * from './query/index.js'
export * from './resource-link.js'
export * from './space.js'
export * from './sync.js'
export * from './sys.js'
export * from './tag.js'
24 changes: 12 additions & 12 deletions lib/types/query/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ export {
EntrySkeletonType,
type ConditionalFixedQueries,
type ConditionalListQueries,
} from './util'
} from './util.js'

export * from './equality'
export * from './existence'
export * from './location'
export * from './order'
export * from './query'
export * from './range'
export * from './reference'
export * from './search'
export * from './select'
export * from './set'
export * from './subset'
export * from './equality.js'
export * from './existence.js'
export * from './location.js'
export * from './order.js'
export * from './query.js'
export * from './range.js'
export * from './reference.js'
export * from './search.js'
export * from './select.js'
export * from './set.js'
export * from './subset.js'
3 changes: 2 additions & 1 deletion lib/utils/resolve-circular.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import mixinStringifySafe from '../mixins/stringify-safe'
import resolveResponse from 'contentful-resolve-response'

import mixinStringifySafe from '../mixins/stringify-safe.js'

export default function resolveCircular(data: any, { resolveLinks, removeUnresolved }): any {
const wrappedData = mixinStringifySafe(data)
if (resolveLinks) {
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/validate-params.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ValidationError } from './validation-error'
import { ValidationError } from './validation-error.js'

function checkLocaleParamIsAll(query) {
if (query.locale === '*') {
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/validate-timestamp.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ValidationError } from './validation-error'
import { ValidationError } from './validation-error.js'

type Options = {
maximum?: number
Expand Down
Loading