Using xregexp within a chrome extension
AlexanderVitecsoftware opened this issue · 1 comments
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.
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