-
Notifications
You must be signed in to change notification settings - Fork 434
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
Webpack issue using extra npm packages #52
Comments
My progress with ChatGPT (no luck):WEBPACK CONFIGURATION:
NumericList.ts:
Inject.ts:
As you can see, inject.ts is self-invoking since it is an entry file. Once I use this code ### const rng = seedrandom(respondentId.toString()); ### in NumericList.ts file, after building with webpack inject.ts is no longer self-invoking. How to fix this? |
Created a demonstration project: https://github.com/DenisTimofijuk/injectIssueExample |
I might have some updates on this. content_script.tsx:
background.ts:
Content script has a console log as soon as it is loaded. I found 2 things: 1.Moving the import and the console.log(sha....) from context script to background solved everything. This would work but imply sending a message to background every time I had to generate SHA of something. 2.Seems like content script does not work well with standard import / export. Using dynamic import for npm packages seems to solve the issue (see this answer on Stackoverflow. After using dynamic import, my content script looks like this:
And everything works as intended. NOTE: This can be easily solved by changing in
to
Also you have to update module in UPDATE: dynamic import seems to lead to a policy violation: UPDATE 2: UPDATE 3: |
I am using inject technology to be able to access window object from my content scripts as per this example: https://gist.github.com/devjin0617/3e8d72d94c1b9e69690717a219644c7a
Everything was working fine until I added npm seedrandom to my inject file. Now when I build my project, inject file is modified in such a way that it no longer is working as it should. Tried various webpack settings, but with no luck. Should this be working by default using such a prebuild environment?
The text was updated successfully, but these errors were encountered: