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

textlint-script-compiler cannot complie when .textlintrc includes textlint-filter-rule-allowlist config #57

Closed
HeRoMo opened this issue Jun 27, 2021 · 3 comments
Labels
Type: Bug Bug or Bug fixes

Comments

@HeRoMo
Copy link

HeRoMo commented Jun 27, 2021

My .textlintrc.yml includes textlint-filter-rule-allowlist config, as the following,

filters:
  comments: true
  allowlist:
    allow: 
      - "/^:::details .+$/m"
rules:
  # ~~ some rules config ~~

I complied my .textlintrc.yml, then errors happened, as bellow.
(my home dir path replaced by $HOME)

❯ ./node_modules/.bin/textlint-script-compiler --output-dir ./dist-test --metadataName "test" --metadataNamespace "https://example.com" --textlintrc ./.textlintrc.yml
[
  {
    moduleIdentifier: '$HOME/.my-textlint-rules/node_modules/require-from-string/index.js',
    moduleName: './node_modules/require-from-string/index.js',
    loc: '3:13-30',
    message: "Module not found: Error: Can't resolve 'module' in '$HOME/.my-textlint-rules/node_modules/require-from-string'",
    moduleId: 46029,
    moduleTrace: [ [Object], [Object], [Object] ],
    details: "resolve 'module' in '$HOME/.my-textlint-rules/node_modules/require-from-string'\n" +
      '  Parsed request is a module\n' +
      '  using description file: $HOME/.my-textlint-rules/node_modules/require-from-string/package.json (relative path: .)\n' +
      "    Field 'browser' doesn't contain a valid alias configuration\n" +
      '    resolve as module\n' +
      "      $HOME/.my-textlint-rules/node_modules/require-from-string/node_modules doesn't exist or is not a directory\n" +
      "      $HOME/.my-textlint-rules/node_modules/node_modules doesn't exist or is not a directory\n" +
      '      looking for modules in $HOME/.my-textlint-rules/node_modules\n' +
      '        single file module\n' +
      '          using description file: $HOME/.my-textlint-rules/package.json (relative path: ./node_modules/module)\n' +
      '            no extension\n' +
      "              Field 'browser' doesn't contain a valid alias configuration\n" +
      "              $HOME/.my-textlint-rules/node_modules/module doesn't exist\n" +
      '            .js\n' +
      "              Field 'browser' doesn't contain a valid alias configuration\n" +
      "              $HOME/.my-textlint-rules/node_modules/module.js doesn't exist\n" +
      '            .json\n' +
      "              Field 'browser' doesn't contain a valid alias configuration\n" +
      "              $HOME/.my-textlint-rules/node_modules/module.json doesn't exist\n" +
      '            .wasm\n' +
      "              Field 'browser' doesn't contain a valid alias configuration\n" +
      "              $HOME/.my-textlint-rules/node_modules/module.wasm doesn't exist\n" +
      "        $HOME/.my-textlint-rules/node_modules/module doesn't exist\n" +
      "      $HOME/node_modules doesn't exist or is not a directory\n" +
      "      /Users/node_modules doesn't exist or is not a directory\n" +
      "      /node_modules doesn't exist or is not a directory",
    stack: "ModuleNotFoundError: Module not found: Error: Can't resolve 'module' in '$HOME/.my-textlint-rules/node_modules/require-from-string'\n" +
      '    at $HOME/.my-textlint-rules/node_modules/webpack/lib/Compilation.js:1768:28\n' +
      '    at $HOME/.my-textlint-rules/node_modules/webpack/lib/NormalModuleFactory.js:732:13\n' +
      '    at eval (eval at create ($HOME/.my-textlint-rules/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:10:1)\n' +
      '    at $HOME/.my-textlint-rules/node_modules/webpack/lib/NormalModuleFactory.js:274:22\n' +
      '    at eval (eval at create ($HOME/.my-textlint-rules/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:9:1)\n' +
      '    at $HOME/.my-textlint-rules/node_modules/webpack/lib/NormalModuleFactory.js:403:22\n' +
      '    at $HOME/.my-textlint-rules/node_modules/webpack/lib/NormalModuleFactory.js:117:11\n' +
      '    at $HOME/.my-textlint-rules/node_modules/webpack/lib/NormalModuleFactory.js:648:24\n' +
      '    at $HOME/.my-textlint-rules/node_modules/webpack/lib/NormalModuleFactory.js:802:8\n' +
      '    at $HOME/.my-textlint-rules/node_modules/webpack/lib/NormalModuleFactory.js:922:5',
    compilerPath: undefined
  }
]
[
  {
    moduleIdentifier: '$HOME/.my-textlint-rules/node_modules/require-from-string/index.js',
    moduleName: './node_modules/require-from-string/index.js',
    loc: '3:13-30',
    message: "Module not found: Error: Can't resolve 'module' in '$HOME/.my-textlint-rules/node_modules/require-from-string'",
    moduleId: 46029,
    moduleTrace: [ [Object], [Object], [Object] ],
    details: "resolve 'module' in '$HOME/.my-textlint-rules/node_modules/require-from-string'\n" +
      '  Parsed request is a module\n' +
      '  using description file: $HOME/.my-textlint-rules/node_modules/require-from-string/package.json (relative path: .)\n' +
      "    Field 'browser' doesn't contain a valid alias configuration\n" +
      '    resolve as module\n' +
      "      $HOME/.my-textlint-rules/node_modules/require-from-string/node_modules doesn't exist or is not a directory\n" +
      "      $HOME/.my-textlint-rules/node_modules/node_modules doesn't exist or is not a directory\n" +
      '      looking for modules in $HOME/.my-textlint-rules/node_modules\n' +
      '        single file module\n' +
      '          using description file: $HOME/.my-textlint-rules/package.json (relative path: ./node_modules/module)\n' +
      '            no extension\n' +
      "              Field 'browser' doesn't contain a valid alias configuration\n" +
      "              $HOME/.my-textlint-rules/node_modules/module doesn't exist\n" +
      '            .js\n' +
      "              Field 'browser' doesn't contain a valid alias configuration\n" +
      "              $HOME/.my-textlint-rules/node_modules/module.js doesn't exist\n" +
      '            .json\n' +
      "              Field 'browser' doesn't contain a valid alias configuration\n" +
      "              $HOME/.my-textlint-rules/node_modules/module.json doesn't exist\n" +
      '            .wasm\n' +
      "              Field 'browser' doesn't contain a valid alias configuration\n" +
      "              $HOME/.my-textlint-rules/node_modules/module.wasm doesn't exist\n" +
      "        $HOME/.my-textlint-rules/node_modules/module doesn't exist\n" +
      "      $HOME/node_modules doesn't exist or is not a directory\n" +
      "      /Users/node_modules doesn't exist or is not a directory\n" +
      "      /node_modules doesn't exist or is not a directory",
    stack: "ModuleNotFoundError: Module not found: Error: Can't resolve 'module' in '$HOME/.my-textlint-rules/node_modules/require-from-string'\n" +
      '    at $HOME/.my-textlint-rules/node_modules/webpack/lib/Compilation.js:1768:28\n' +
      '    at $HOME/.my-textlint-rules/node_modules/webpack/lib/NormalModuleFactory.js:732:13\n' +
      '    at eval (eval at create ($HOME/.my-textlint-rules/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:10:1)\n' +
      '    at $HOME/.my-textlint-rules/node_modules/webpack/lib/NormalModuleFactory.js:274:22\n' +
      '    at eval (eval at create ($HOME/.my-textlint-rules/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:9:1)\n' +
      '    at $HOME/.my-textlint-rules/node_modules/webpack/lib/NormalModuleFactory.js:403:22\n' +
      '    at $HOME/.my-textlint-rules/node_modules/webpack/lib/NormalModuleFactory.js:117:11\n' +
      '    at $HOME/.my-textlint-rules/node_modules/webpack/lib/NormalModuleFactory.js:648:24\n' +
      '    at $HOME/.my-textlint-rules/node_modules/webpack/lib/NormalModuleFactory.js:802:8\n' +
      '    at $HOME/.my-textlint-rules/node_modules/webpack/lib/NormalModuleFactory.js:922:5',
    compilerPath: undefined
  }
]

When I remove filters.allowlist config from .textlint.yml, textlint-script-compiler can compile successfully.

@azu azu added the Type: Bug Bug or Bug fixes label Jun 27, 2021
@azu
Copy link
Member

azu commented Jun 27, 2021

https://github.com/textlint/textlint-filter-rule-allowlist/blob/f336ba1dc0e37fc8bc7f32ad2e789b95e8196c7b/package.json#L52
Probably, this error caused by textlint-filter-rule-allowlist's dependencies.
webpack can not support module module that is Node.js specific parts.

Probably, we need to remove rc-config-loader from textlint-filter-rule-allowlist's dependencies.
Or, we need to make the import statement on-demand like dynamic import.

@azu
Copy link
Member

azu commented Jun 27, 2021

resolve: {
fallback: {
fs: false
}
},

We may resolve this by adding module: false, which I do not test yet.

@azu
Copy link
Member

azu commented Oct 7, 2021

probably, fixed in textlint/textlint-filter-rule-allowlist#11

@azu azu closed this as completed Oct 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Bug or Bug fixes
Projects
None yet
Development

No branches or pull requests

2 participants