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

[BUG] Fix console warnings about 'Query' export #1063

Closed
JohnathonBowers opened this issue Oct 5, 2023 · 13 comments
Closed

[BUG] Fix console warnings about 'Query' export #1063

JohnathonBowers opened this issue Oct 5, 2023 · 13 comments
Assignees
Labels
bug Something isn't working OSCI

Comments

@JohnathonBowers
Copy link
Contributor

Describe the bug

When I try to run the OUI documentation site, I see a number of warnings in my console regarding a missing export 'Query'.

To Reproduce
Steps to reproduce the behavior:

  1. Fork the OUI repo and clone it to your local machine
  2. Run yarn install and then yarn start
  3. Visit localhost:8030 on your browser (Chrome, in my case)
  4. Right click on browser screen, choose 'Inspect'
  5. Click on the 'Console' tab

Expected behavior

These warnings should not appear. :)

Screenshots

Screenshot 2023-10-05 at 5 06 46 PM

Host/Environment (please complete the following information):

  • OUI Version: 1.22.19
  • OSD Version (if applicable): N/A
  • OS: macOS Ventura 13.5.2
  • Browser and version: Chrome (Version 116.0.5845.187 (Official Build))

Additional context

N/A

@JohnathonBowers JohnathonBowers added bug Something isn't working untriaged labels Oct 5, 2023
@BSFishy BSFishy removed the untriaged label Oct 5, 2023
@BSFishy
Copy link
Contributor

BSFishy commented Oct 5, 2023

This appears to be an issue with (maybe?) Typescript and exporting the Query/Ast types (the logs in the console that say they're warnings). See #770 (comment)

I've been investigating this for a little bit and can't find anything on my end. What Babel outputs (which runs after Typescript) has correct exports, so this is maybe just a bug in Webpack.

This will probably be a matter of changing lines that say

import { Query } from './query';

into

import { Query } from './query/query';

Most likely will need this change in

  • src/components/search_bar/index.ts
  • src/components/search_bar/search_bar.test.tsx
  • src/components/search_bar/search_bar.tsx
  • src/components/search_bar/search_filters.test.tsx
  • src/components/search_bar/search_filters.tsx

You can see how those files are change in #770 for these changes

@JohnathonBowers
Copy link
Contributor Author

Is it okay to also address the issue with the 'Ast' import as a part of this bug fix, or should I just focus on the 'Query' import?

@BSFishy
Copy link
Contributor

BSFishy commented Oct 5, 2023

Is it okay to also address the issue with the 'Ast' import as a part of this bug fix, or should I just focus on the 'Query' import?

Yeah definitely. No need in creating multiple PR/issues if they are related :)

@JohnathonBowers
Copy link
Contributor Author

JohnathonBowers commented Oct 6, 2023

I was able to update the path names like you suggested and get the site to run . It appears that ./query was directing to .query/index (see screenshot below), so changing the path names to .query/query did the trick.

Screenshot 2023-10-05 at 8 39 05 PM

I've tried to fix the warning in my console about export 'Ast' was not found in './search_bar'. However, I'm not seeing what is causing the problem.

Screenshot 2023-10-06 at 12 50 13 AM

The entry point for the warning is src/components/search_bar/index.ts. The relevant block is below:

Screenshot 2023-10-06 at 12 13 03 AM

'Ast' is being exported from src/components/search_bar/search_bar.tsx. There, on line 40, 'AST' is being exported as 'Ast':

Screenshot 2023-10-06 at 12 22 50 AM

So, I'm not sure what is causing this particular warning. Any thoughts?

@AwesomeSauce42
Copy link

Hi, tried to reproduce this error, but my console doesn't show any warnings.
image

@BSFishy
Copy link
Contributor

BSFishy commented Oct 9, 2023

So, I'm not sure what is causing this particular warning. Any thoughts?

Yeah, most likely you'll need to make a separate export in src/components/search_bar/search_bar.tsx:

export { Query } from './query/query';
export { AST as Ast } from './query/ast';

@JohnathonBowers
Copy link
Contributor Author

I tried the fix you suggested, but I'm still getting the warning in my browser console:

Screenshot 2023-10-10 at 7 41 37 PM Screenshot 2023-10-10 at 7 42 18 PM

I've done some digging, and, as best I can tell, I think the issue is arising when 'AST' is being exported under an alias. I tried getting rid of the alias in this file and the other files that use it, and the warning disappears from my browser console:

Screenshot 2023-10-10 at 7 53 25 PM Screenshot 2023-10-10 at 7 54 00 PM

@joshuarrrr
Copy link
Member

@JohnathonBowers Go ahead with that fix to de-alias AST. I still wish we had a better understanding of what's causing the issue, and why it only appeared recently. @AMoo-Miki Is this something you recognize at all from other bundling/building work?

@JohnathonBowers
Copy link
Contributor Author

Sounds good, @joshuarrrr . Is it okay to open up a separate issue for this, or would you prefer that I keep the fix in the same PR as the Query path fix?

@joshuarrrr
Copy link
Member

separate PR/issue is always welcome

@AMoo-Miki
Copy link
Collaborator

@AMoo-Miki Is this something you recognize at all from other bundling/building work?

@joshuarrrr yes. Something similar came up when upgrading webpack: #770 (comment)

@BSFishy
Copy link
Contributor

BSFishy commented Oct 13, 2023

I said this in Slack, but my theory is something along the lines that Webpack has some sort of bug on Mac in v4 and always in v5 that causes this. Potentially some sort of platform-specific optimization in v4, since this only popped up when people started using Mac's to develop. I checked the Babel output for both CJS and ESM for these files, and they seem just fine, even work without any problems with Node. In my mind, that only leaves Webpack as the culprit of this issue. Potentially Webpack trying to perform some sort of transpilation for an older target??

@JohnathonBowers
Copy link
Contributor Author

JohnathonBowers commented Oct 13, 2023

@BSFishy @joshuarrrr I just opened a new issue for the AST fix (Issue #1081 ). Mind assigning it to me when you get a chance?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working OSCI
Projects
None yet
Development

No branches or pull requests

5 participants