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

Unable to load jquery.js file under content script directory #76

Open
Kain-90 opened this issue Mar 16, 2024 · 3 comments
Open

Unable to load jquery.js file under content script directory #76

Kain-90 opened this issue Mar 16, 2024 · 3 comments

Comments

@Kain-90
Copy link

Kain-90 commented Mar 16, 2024

Everything is fine during the dev mode, but after run yarn build and reload the extension, the dev console shows the error:
image

I can find jquery.js in the Sources tab, and $ can be successfully called in the dev console
image

manifest.ts content like below

  content_scripts: [
    {
      matches: omit,
      js: [
        'src/contentScript/jquery.js',
        'src/contentScript/index.ts',
      ],
      css: omit,
      run_at: 'document_start',
    },
  ],
@sakibul-islam
Copy link
Contributor

Try importing jQuery directly in your index.ts

Install jQuery

yarn add jquery

index.ts

import $ from "jquery";

@Kain-90
Copy link
Author

Kain-90 commented Mar 17, 2024

Try importing jQuery directly in your index.ts

Install jQuery

yarn add jquery

index.ts

import $ from "jquery";

Thank you for your advice.
I haven't tested it yet, because jquery.js is just one example. If otherA.js contains a function A and otherB.js contains a function B, how should I call these methods A and B in index.ts?

@sakibul-islam
Copy link
Contributor

Try importing jQuery directly in your index.ts

Install jQuery

yarn add jquery

index.ts

import $ from "jquery";

Thank you for your advice. I haven't tested it yet, because jquery.js is just one example. If otherA.js contains a function A and otherB.js contains a function B, how should I call these methods A and B in index.ts?

Check Modules documentation:

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

No branches or pull requests

2 participants