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

force esm via tsconfig, remove package.json creation #2199

Open
wants to merge 23 commits into
base: main
Choose a base branch
from

Conversation

josefaidt
Copy link
Contributor

Problem

follow-up to #2084

The purpose of the existing amplify/package.json file is to force the backend project to be an ESM project, and treat all backend project files as ES modules. The existence of this file and the one created at the project root (i.e. above amplify/) can be confusing as it is often used to define dependencies. There have been a few reports of the confusing experience as modules will resolve as they are installed during sandbox, but are not resolved during branch builds using the default configuration, and customer branch deployments fail.

This change is largely from the guidance from the official tsx docs's recommendation

{
	"compilerOptions": {

		// Treat files as modules even if it doesn't use import/export
		"moduleDetection": "force",

		// Ignore module structure
		"module": "Preserve",

		// Allow JSON modules to be imported
		"resolveJsonModule": true,

		// Allow JS files to be imported from TS and vice versa
		"allowJs": true,

		// Use correct ESM import behavior
		"esModuleInterop": true,

		// Disallow features that require cross-file awareness
		"isolatedModules": true,
	},
}

This change:

  • changes module from es2022 to preserve
  • removes moduleResolution
  • adds moduleDetection with force
  • removes package.json creation

Existing customers will not be impacted, and no changes are required on their part, however later it will be noticed that create-amplify no longer creates the same files or configuration.

Moving forward, would it benefit us from creating the tsconfig.json inside .amplify/ (creating this file preemptively), and extend-ing it from the customer's amplify/ directory? This would allow us to make further changes to this file and create on demand since it is gitignored.

Issue number, if available:

Changes

Corresponding docs PR, if applicable:

Validation

Checklist

  • If this PR includes a functional change to the runtime behavior of the code, I have added or updated automated test coverage for this change.
  • If this PR requires a change to the Project Architecture README, I have included that update in this PR.
  • If this PR requires a docs update, I have linked to that docs PR above.
  • If this PR modifies E2E tests, makes changes to resource provisioning, or makes SDK calls, I have run the PR checks with the run-e2e label set.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@josefaidt josefaidt requested a review from a team as a code owner November 5, 2024 16:22
Copy link

changeset-bot bot commented Nov 5, 2024

🦋 Changeset detected

Latest commit: 6331f8c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
create-amplify Patch
@aws-amplify/cli-core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@josefaidt josefaidt added the run-e2e Label that will include e2e tests in PR checks workflow label Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
run-e2e Label that will include e2e tests in PR checks workflow
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant