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

fix: use correct loader for journey files #626

Merged
merged 1 commit into from
Oct 19, 2022

Conversation

vigneshshanmugam
Copy link
Member

@vigneshshanmugam vigneshshanmugam commented Oct 18, 2022

  • fix [Project monitors] Push command unable to parse TypeScript #625

  • When journey files are pushed, We treat these files differently when bundling

    1. Entry paths - Journey files
    2. Imported paths - Other deps / local files imported by the journey files itself.
  • When the journey files are loaded by the bundler, the underlying loader in the ES build was defaulting to JS which throws error when Typescript types are used inside the journey files. This PR fixes the problem by using appropriate loader for the journey files when push command is invoked. The test is also added to ensure this does not break in the future.

Testing

  1. Build the PR - npm run build
  2. Create an example journey, example.journey.ts
  3. Use the example below which relies on TS typings
const createJourney = (name: string) => {  // TS types
  journey(name, ({ page, params }) => {
    step('launch application', async () => {
      await page.goto(params.url);
    });
  });
};

['a', 'b'].forEach(a => createJourney(a));
  1. Run SYNTHETICS_API_KEY="" npm run push

@@ -39,6 +39,11 @@ export function commonOptions(): esbuild.BuildOptions {
bundle: true,
external: ['@elastic/synthetics'],
minify: false,
minifyIdentifiers: false,
Copy link
Member Author

Choose a reason for hiding this comment

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

not related to this change, but ensures we never minify the journey files.

@apmmachine
Copy link

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2022-10-18T20:26:11.843+0000

  • Duration: 14 min 24 sec

Test stats 🧪

Test Results
Failed 0
Passed 203
Skipped 2
Total 205

🤖 GitHub comments

Expand to view the GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

Copy link
Contributor

@dominiqueclarke dominiqueclarke left a comment

Choose a reason for hiding this comment

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

LGTM. Error is no longer reported.

@vigneshshanmugam vigneshshanmugam merged commit a81b1b6 into elastic:main Oct 19, 2022
@vigneshshanmugam vigneshshanmugam deleted the fix-bundle-load branch October 19, 2022 17:12
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.

[Project monitors] Push command unable to parse TypeScript
3 participants