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

Using xregexp within a chrome extension #334

Open
AlexanderVitecsoftware opened this issue Sep 1, 2021 · 1 comment
Open

Using xregexp within a chrome extension #334

AlexanderVitecsoftware opened this issue Sep 1, 2021 · 1 comment

Comments

@AlexanderVitecsoftware
Copy link

Hi just letting you guys know that a team member of mine introduced this npm package to our chrome extension project. Afterwards when I build the project for a release artifact using webpack and try to add the artifact to the chrome browser then chrome prompts me this issue:

Could not load file 'pages/defaulthighlighthandler.js' for content script. It isn't UTF-8 encoded.

The defaulthighlighthandler.js is simply the file within my build that is implementing the code using xregexp.

I resolved this by uninstalling the xregexp package, and we are now using the buildin js regex API.

My team member simply used the following to trigger the issue:

import XRegExp from 'xregexp';

const unicodeLetter = XRegExp('^\\pL+$');

if (unicodeLetter.test(selectedText)) {
   ...
}

I have following dependencies:

node: v12.22.1
npm: v6.14.12
tsc: v4.3.2

"webpack": "^4.35.0",
"webpack-cli": "^3.3.5",
"react": "^16.12.0",

Hope it can help you and I will do my best to answer questions.

@AlexanderVitecsoftware AlexanderVitecsoftware changed the title Using xregexp within a chrome extension. Using xregexp within a chrome extension Sep 1, 2021
@josephfrazier
Copy link
Collaborator

Hey @AlexanderVitecsoftware , I searched for the error message you posted, and it sounds like you may be able to update your webpack configuration to fix this: https://stackoverflow.com/questions/49979397/chrome-says-my-content-script-isnt-utf-8/58528858#58528858

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