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

chore: update script library #939

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

Conversation

Mercy811
Copy link
Contributor

Summary

  • Change library to amplitude-ts-sdk-script in amplitude-min.js which is renamed as analytics-browser-x.x.x-min.js.gzand uploaded to s3 at
    const files = ['amplitude-min.js.gz', 'amplitude-min.umd.js.gz'];
  • The main goal is to be able to distinguish installation methods: script vs npm/yarn which remains to be amplitude-ts
// install by script example
<script src="https://cdn.amplitude.com/libs/analytics-browser-2.11.10-min.js.gz"></script>
  • Keep this as part of rollup instead of updating amplitude-min.js to avoid amplitude-min.js is used before library updated
  • library in lib/esm and lib/cjs remains amplitude-ts
image

Checklist

  • Does your PR title have the correct title format?
  • Does your PR have a breaking change?:

const path = 'src/lib-prefix.ts'
if (!fs.existsSync(path)) {
// Supported in rollup 4, we're currently rollup 2
// this.error(`File not found: ${path}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor, do we want to keep this logging comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd like to keep it here so that when we migrate to rollup 4, we can just uncomment this line. wdyt?

}

fs.writeFileSync(path, updatedContent, 'utf-8');
// this.info(`File updated: ${path}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto

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 same as above #939 (comment)

Choose a reason for hiding this comment

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

Nit: Should we also add the comment // Supported in rollup 4, we're currently rollup 2 here for clarity

@@ -63,6 +97,7 @@ export const iife = {
sourcemap: true,
},
plugins: [
updateLibPrefixPlugin(),
Copy link
Contributor

Choose a reason for hiding this comment

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

I think another possible solution is using https://www.npmjs.com/package/rollup-plugin-inject-process-env, so we can dynamically inject environment variable here, then read in the build process.
Manipulating the library file solution LGTM too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great solution! I'll make it as a backup if the plugin solution doesn't work well.

@Mercy811 Mercy811 requested a review from chungdaniel December 24, 2024 22:13
}


const updateLibPrefixPlugin = (isUndo) => {

Choose a reason for hiding this comment

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

Doesn't look like isUndo is used here

}

fs.writeFileSync(path, updatedContent, 'utf-8');
// this.info(`File updated: ${path}`);

Choose a reason for hiding this comment

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

Nit: Should we also add the comment // Supported in rollup 4, we're currently rollup 2 here for clarity

@@ -54,6 +55,39 @@ export const umd = {
],
};

const updateLibPrefix = (isUndo) => {

Choose a reason for hiding this comment

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

Nit: Should function name give a bit more context? Not sure if I'm just unfamiliar with rollup/context of the PR. isUndo makes a bit more sense with some context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants