1

I have a requirement to check if the passwords created by users are not dictionary words.

The code I have works fine on a small set of test words:

class PasswordHelper {

    static passwordContainsDictionaryWord(password) {
        return this.WORDS.has(password)
    }

    static WORDS = new Set(["football", "cricket", "basketball"]);
}

export default PasswordHelper;

When I replace my set of test words with a large set of dictionary words (a total of 3M characters), my Vue compiler freezes on the file.

I went away for lunch and the compiler eventually gave up after throwing the following warning:

[BABEL] Note: The code generator has deoptimised the styling of \src\helper\passwordhelper.js as it exceeds the max of 500KB.

Adding the following configuration to my webpack config did not improve the situation:

loaders: [
    { test: /\.js$/, loader: 'babel', query: {compact: false} }
]

Any ideas how I might get around this problem?

EDIT: Questions linked are NOT duplicates. The OPs in the linked questions are simply asking about warnings they are seeing in the logs and have not experienced issues blocking their compiling. Setting Babel to produce compact or non-compact output does NOT effect my problem, it freezes in either case.

F_SO_K
  • 13,640
  • 5
  • 54
  • 83
  • [This](https://stackoverflow.com/questions/29576341/what-does-the-code-generator-has-deoptimised-the-styling-of-some-file-as-it-e) might help. – maazadeeb Mar 07 '19 at 15:47
  • Possible duplicate of [BABEL Note: The code generator has deoptimised the styling of "app.js" as it exceeds the max of "100KB in Meteor](https://stackoverflow.com/questions/35192796/babel-note-the-code-generator-has-deoptimised-the-styling-of-app-js-as-it-exc) – stdob-- Mar 07 '19 at 15:47
  • How about move the `passwordContainsDictionaryWord` function on the backend side? – stdob-- Mar 07 '19 at 15:58
  • Yes, that will be my backup option if I can't get it working at the front-end. – F_SO_K Mar 07 '19 at 16:05
  • 1
    I would try to make the `WORDS` array a JSON file and require it in the PasswordHelper file, so it wouldn't be necessary to compile that big file at all. – Andrey Mar 07 '19 at 16:16
  • Good idea - I will try that now – F_SO_K Mar 07 '19 at 16:17
  • 1
    @Andrey That worked - thanks. Do you want to post an answer and I will upvote and accept. – F_SO_K Mar 07 '19 at 16:27

0 Answers0