Skip to content

Commit

Permalink
perf: remove ESM loader to speed up CLI execution (#9873)
Browse files Browse the repository at this point in the history
* perf: remove ESM loader to speed up CLI execution

Removed ESM loader for NPM CLI installation and update all the packages to be transpiled using
typescript to covert all ES6 import export statements to commonjs format

* build: remove esm from post-install script

* build: transpile interaction category and copy asset files to lib dir

* build: copy additional templates part of build step

* fixup: address review comment

Co-authored-by: Yathi <511386+yuth@users.noreply.github.com>
  • Loading branch information
jhockett and yuth committed Mar 4, 2022
1 parent d4218a9 commit 46ada02
Show file tree
Hide file tree
Showing 133 changed files with 824 additions and 766 deletions.
5 changes: 5 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,11 @@ module.exports = {
'/packages/amplify-category-auth/resources/auth-custom-resource',
'/packages/amplify-category-custom/lib',
'/packages/amplify-category-custom/resources',
'/packages/amplify-console-hosting/lib/',
'/packages/amplify-container-hosting/lib/',
'/packages/amplify-category-predictions/lib',
'/packages/amplify-category-analytics/lib',
'/amplify-category-interactions/lib',
'/packages/amplify-category-custom/src/utils/generate-cfn-from-cdk.ts',

// Ignore CHANGELOG.md files
Expand Down
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ test.out.log
packages/amplify-graphiql-explorer/.eslintcache
packages/amplify-cli-extensibility-helper/lib
packages/amplify-cli-overrides-helper/lib
packages/amplify-console-hosting/lib/
packages/amplify-container-hosting/lib/
packages/amplify-category-predictions/lib
packages/amplify-category-analytics/lib
packages/amplify-category-interactions/lib/
!packages/amplify-graphql-model-transformer/src/__tests__/overrides/build/override.js


7 changes: 6 additions & 1 deletion packages/amplify-category-analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@
},
"author": "Amazon Web Services",
"license": "Apache-2.0",
"main": "index.js",
"main": "lib/index.js",
"keywords": [
"amplify",
"aws"
],
"scripts": {
"build": "tsc",
"clean": "rimraf lib tsconfig.tsbuildinfo",
"watch": "tsc --watch"
},
"dependencies": {
"amplify-cli-core": "2.4.16",
"fs-extra": "^8.1.0",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Kinesis resource stack creation using Amplify CLI",
"Parameters": {
"env": {
"Type": "String"
},
"kinesisStreamName": {
"Type": "String"
},
"kinesisStreamShardCount": {
"Type": "Number",
"Default": 1
},
"authPolicyName": {
"Type": "String"
},
"unauthPolicyName": {
"Type": "String"
},
"authRoleName": {
"Type": "String"
},
"unauthRoleName": {
"Type": "String"
}
},
"Conditions": {
"ShouldNotCreateEnvResources": {
"Fn::Equals": [{ "Ref": "env" }, "NONE"]
}
},
"Resources": {
"KinesisStream": {
"Type": "AWS::Kinesis::Stream",
"Properties": {
"Name": {
"Fn::Join": ["-", [{ "Ref": "kinesisStreamName" }, { "Ref": "env" }]]
},
"ShardCount": { "Ref": "kinesisStreamShardCount" }
}
},
"CognitoUnauthPolicy": {
"Type": "AWS::IAM::Policy",
"Properties": {
"PolicyName": { "Ref": "unauthPolicyName" },
"Roles": [{ "Ref": "unauthRoleName" }],
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["kinesis:PutRecord", "kinesis:PutRecords"],
"Resource": {
"Fn::GetAtt": ["KinesisStream", "Arn"]
}
}
]
}
}
},
"CognitoAuthPolicy": {
"Type": "AWS::IAM::Policy",
"Properties": {
"PolicyName": { "Ref": "authPolicyName" },
"Roles": [{ "Ref": "authRoleName" }],
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["kinesis:PutRecord", "kinesis:PutRecords"],
"Resource": {
"Fn::GetAtt": ["KinesisStream", "Arn"]
}
}
]
}
}
}
},
"Outputs": {
"kinesisStreamArn": {
"Value": { "Fn::GetAtt": ["KinesisStream", "Arn"] }
},
"kinesisStreamId": {
"Value": { "Ref": "KinesisStream" }
},
"kinesisStreamShardCount": {
"Value": { "Ref": "kinesisStreamShardCount" }
}
}
}
24 changes: 24 additions & 0 deletions packages/amplify-category-analytics/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "lib",
"rootDir": "src",
"allowJs": true,
"strictPropertyInitialization": false,
"inlineSources": true
},
"include": [
"src/**/*",
"src/provider-utils/**/*.json",
],
"exclude": [
"coverage",
"lib",
"resources",
"scripts",
"src/__tests__"
],
"references": [
{ "path": "../amplify-cli-core" }
]
}
8 changes: 7 additions & 1 deletion packages/amplify-category-interactions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@
},
"author": "Amazon Web Services",
"license": "Apache-2.0",
"main": "index.js",
"main": "lib/index.js",
"keywords": [
"amplify",
"aws"
],
"scripts": {
"build": "tsc && yarn copy-templates",
"clean": "rimraf lib tsconfig.tsbuildinfo",
"watch": "tsc --watch",
"copy-templates": "copyfiles -u 4 src/provider-utils/awscloudformation/cloudformation-templates/* lib/provider-utils/awscloudformation/cloudformation-templates/ && yarn copyfiles -u 4 src/provider-utils/awscloudformation/function-template-dir/*.ejs lib/provider-utils/awscloudformation/function-template-dir/"
},
"dependencies": {
"amplify-cli-core": "2.4.16",
"fs-extra": "^8.1.0",
Expand Down

0 comments on commit 46ada02

Please sign in to comment.