-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
feat(repo): set up rollup to emit esm and cjs artifacts #12522
Conversation
Please ensure that this PR:
A repository administrator is required to review & merge this change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! Some suggestions & questions below. We should merge & squash this when the time comes to keep things tidy
@@ -10,7 +10,7 @@ import { | |||
import { NextApiRequestMock, NextApiResponseMock } from '../mocks/headers'; | |||
import { createServerRunnerForAPI } from '../../src/api/createServerRunnerForAPI'; | |||
|
|||
const headers = import('next/headers'); | |||
const headers = import('next/headers.js'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewer context: Required because Next.js vends ESM artifacts as JS (same with Lodash)
plugins: [ | ||
typescript({ | ||
...cjsTSOptions, | ||
tsconfig: 'tsconfig.build.json', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to use tsconfig.json
or tsconfig.build.json
for this package? In other packages I believe tsconfig.build.json
was only used for the ts-coverage
check and has been getting removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should the common pattern
tsconfig.json
for devtsconfig.build.json
for build
We can apply this pattern in a separate PR though.
"@rollup/plugin-typescript": "11.1.5", | ||
"rollup": "3.29.4", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can these be moved to the workspace dev dependencies
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't do unfortunately, until we are able use a consistent typescript version in the workspace, and get rid of the 0.x version of rollup from the workspace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TypeScript version are fine to align. And workspace rollup version is for building CDN artifacts that TBH should not be part of the package build script. We can take a followup item to streamline this
033a710
to
180c915
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this much needed change @HuiSF I don't have any blocking comments. 🚀🚀🚀
@@ -1,5 +0,0 @@ | |||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Any context on removing the internals folder?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was required originally by GraphQL client server APIs, but these APIs are now moved into adapter-next/api
. The internals are no longer needed.
@@ -3,7 +3,7 @@ | |||
import { AmplifyClassV6 } from '@aws-amplify/core'; | |||
import { Category, ApiAction } from '@aws-amplify/core/internals/utils'; | |||
import { GraphQLOptions, GraphQLResult } from './types'; | |||
import { InternalGraphQLAPIClass } from './internals'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For review context: this is required to prevent circular dependencies.
@HuiSF Can we add a little comment here as well?
'./lib-esm/auth/index.js', | ||
'./lib-esm/auth/cognito/index.js', | ||
'./lib-esm/storage/index.js', | ||
'./lib-esm/storage/s3/index.js', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-blocking -- This list should include all the packages under the dist folder, like in v5. We can address this separately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the original set up is to create a umd bundle for supported CDN script use cases. We can revisit this part separately.
@@ -1,8 +1,5 @@ | |||
{ | |||
"main": "../lib/ssr/index.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super nit: add a name
indicating the import path.
c31a8d1
to
4672524
Compare
"build:cjs:watch": "rimraf dist/cjs && tsc -m commonjs --outDir dist/cjs --watch", | ||
"build:esm:watch": "rimraf dist/esm && tsc -m esnext --outDir dist/esm --watch", | ||
"build": "npm run clean && npm run build:esm-cjs && npm run build:umd", | ||
"clean": "npm run clean:size && rimraf dist lib lib-esm", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: do we need to reference lib
and lib-esm
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did this just to clean up old build artifacts locally once this gets merged
"typescript": "5.0.2" | ||
}, | ||
"size-limit": [ | ||
{ | ||
"name": "API (rest client)", | ||
"path": "./lib-esm/index.js", | ||
"path": "./dist/esm/index.mjs", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we can remove this size-limit
if is not used on this package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure I can clean all these up in separate PR.
"./dist/cjs/API.js", | ||
"./dist/esm/API.mjs" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AllanZhengYP do we need this side effect?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These side effect entries have been removed at 4672524
packages/datastore/ssr/package.json
Outdated
"../lib/ssr/index": "../lib-esm/ssr/index.js" | ||
} | ||
"main": "../dist/cjs/ssr/index.js", | ||
"module": "../dist/esm/ssr/index.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be mjs
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DataStore is no longer support SSR, will remove this subpath.
"require": "./lib/index.js" | ||
"types": "./dist/esm/index.d.ts", | ||
"import": "./dist/esm/index.mjs", | ||
"require": "./dist/cjs/index.js" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is missing react-native
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think interactions
doesn't support RN atm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found a couple of things, let me know if that helped
Co-authored-by: Jim Blanchard <[email protected]>
9e2cc9b
to
801bf03
Compare
Description of changes
Notable Changes to The Packages Besides the Rollup Set Up
packages/auth
Rollup generates extra modules for
credentialsProvider
due to unresolvable circular dependencies.packages/storage
Following the Node ESM, the transformed files include fully resolved module import path. With this the original Storage runtime
package.json
module resolution stopped working. To resolve this, this PR moved runtime module resolution into the package rootpackage.json
using the fully resolved module paths.Issue #, if available
Description of how you validated changes
Checklist
yarn test
passesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.