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

"Uncaught SyntaxError: import declarations may only appear at top level of a module" #540

Closed
mccalluc opened this issue Oct 21, 2022 · 8 comments
Assignees

Comments

@mccalluc
Copy link
Contributor

mccalluc commented Oct 21, 2022

I've just deployed v0.32.0 to staging. I logged in, and I'm trying to click on the button with my NetID, but no pulldown appears: Instead in the console I see this error:

Uncaught SyntaxError: import declarations may only appear at top level of a module

(This is not a recipe for a reproducer... I'm not sure exactly what I did before I got here.)

The link to the bad JS is https://vpn.princeton.edu/https/pdc-describe-staging.princeton.edu/describe/vite/assets/application.4e0043f6.js

pan_eval((function(){
import"./jquery-ui-triggeredAutocomplete.1ed59131.js";....................

(following code truncated)

It seems that the asset bundler isn't handling ES Modules? I'm not sure if this code changed recently.

@mccalluc mccalluc added the bug label Oct 21, 2022
@hectorcorrea
Copy link
Member

hectorcorrea commented Oct 21, 2022

@mccalluc for what is worth, the file referenced jquery-ui-triggeredAutocomplete.js is a bit of an outlier. This is a jQuery plug-in that we are customizing for this project (since there is no official working release).

I wonder if we could/should pull this file out of the pipeline and reference it another way, for example via ./public/

@mccalluc
Copy link
Contributor Author

More info: The pulldown with the NetID works on initial load of /describe/, or /describe/users/cm7575... but if I'm on /describe/ and click on "My Dashboard" or "About", I get the error in the console.

@mccalluc
Copy link
Contributor Author

I'm also seeing this on production, so it may not be a new error.

@mccalluc
Copy link
Contributor Author

This doesn't show up in the dev environment: it's related to the production asset pipeline... I also wasn't able to run production locally:

 Missing `secret_key_base` for 'production' environment, set this string with `bin/rails credentials:edit` (ArgumentError)

... and trying to precompile assets and tweak dev config didn't work either... but it probably could have.

Looking at the history: This was introduced in application.html.erb in

and moved to application.js in

I'll try reverting that and deploying to stage.

@mccalluc
Copy link
Contributor Author

Important -- The key to reproducing this is coming to the site via a VPN proxy URL like https://vpn.princeton.edu/https/pdc-describe-prod.princeton.edu/describe/

@kelynch
Copy link
Contributor

kelynch commented Jan 25, 2023

Let's investigate this issue. Do we need to take action in the code?

@jrgriffiniii jrgriffiniii self-assigned this Jan 25, 2023
@jrgriffiniii
Copy link
Contributor

I am struggling to reproduce this error. As such, I am going to please propose that this be reviewed.

@jrgriffiniii
Copy link
Contributor

As I still could not reproduce this error, I am going to close this in order to proceed.

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 a pull request may close this issue.

4 participants