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

TypeError: Cannot read property 'split' of undefined #61

Closed
Lilja opened this issue Jan 19, 2021 · 13 comments · Fixed by #62
Closed

TypeError: Cannot read property 'split' of undefined #61

Lilja opened this issue Jan 19, 2021 · 13 comments · Fixed by #62

Comments

@Lilja
Copy link

Lilja commented Jan 19, 2021

  • Operating System: Mac os
  • Node Version: v12.14.1
  • Yarn Version: 1.22.5
  • webpack Version:
  • eslint-webpack-plugin Version:
    Not too sure what webpack version I'm using as it's bootstrapped using vue-cli tools.
  "dependencies": {
    "@fullstory/browser": "^1.4.6",
    "@funnel-io/nav-plugin-api": "^1.9.0",
    "core-js": "^3.6.5",
    "git-describe": "^4.0.4",
    "vue": "3.0.5"
  },
  "devDependencies": {
    "@sentry/webpack-plugin": "^1.14.0",
    "@typescript-eslint/eslint-plugin": "^4.9.1",
    "@typescript-eslint/parser": "^4.9.1",
    "@vue/cli-plugin-babel": "^5.0.0-alpha.2",
    "@vue/cli-plugin-eslint": "^5.0.0-alpha.2",
    "@vue/cli-plugin-typescript": "^5.0.0-alpha.2",
    "@vue/cli-service": "^5.0.0-alpha.2",
    "@vue/compiler-sfc": "^3.0.0-beta.1",
    "@vue/eslint-config-typescript": "^7.0.0",
    "eslint": "^7.15.0",
    "eslint-plugin-vue": "7.3.0",
    "typescript": "^4.1.3"
  }

Stacktrace

lilja in ~/c/u/customs-data-form on typescript λ make serve
yarn run serve
yarn run v1.22.5
warning ../../package.json: No license field
$ vue-cli-service serve
 INFO  Starting development server...
10% building 0/6 entries 2/6 dependencies 0/1 modules/Users/lilja/code/umbrella/customs-data-form/node_modules/eslint-webpack-plugin/dist/index.js:93
        const file = module.resource.split('?')[0];
                                     ^

TypeError: Cannot read property 'split' of undefined
    at processModule (/Users/lilja/code/umbrella/customs-data-form/node_modules/eslint-webpack-plugin/dist/index.js:93:38)
    at Hook.eval [as call] (eval at create (/Users/lilja/code/umbrella/customs-data-form/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:7:1)
    at /Users/lilja/code/umbrella/customs-data-form/node_modules/webpack/lib/Compilation.js:1262:33
    at /Users/lilja/code/umbrella/customs-data-form/node_modules/webpack/lib/HookWebpackError.js:69:3
    at Hook.eval [as callAsync] (eval at create (/Users/lilja/code/umbrella/customs-data-form/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
    at Cache.store (/Users/lilja/code/umbrella/customs-data-form/node_modules/webpack/lib/Cache.js:107:20)
    at CacheFacade.store (/Users/lilja/code/umbrella/customs-data-form/node_modules/webpack/lib/CacheFacade.js:282:15)
    at /Users/lilja/code/umbrella/customs-data-form/node_modules/webpack/lib/Compilation.js:1254:26
    at /Users/lilja/code/umbrella/customs-data-form/node_modules/webpack/lib/ContextModule.js:439:6
    at jobDone (/Users/lilja/code/umbrella/customs-data-form/node_modules/webpack/lib/FileSystemInfo.js:1676:5)
    at FileSystemInfo.createSnapshot (/Users/lilja/code/umbrella/customs-data-form/node_modules/webpack/lib/FileSystemInfo.js:1954:3)
    at /Users/lilja/code/umbrella/customs-data-form/node_modules/webpack/lib/ContextModule.js:430:31
    at /Users/lilja/code/umbrella/customs-data-form/node_modules/webpack/lib/ContextModuleFactory.js:376:7
    at done (/Users/lilja/code/umbrella/customs-data-form/node_modules/neo-async/async.js:2931:13)
    at /Users/lilja/code/umbrella/customs-data-form/node_modules/webpack/lib/ContextModuleFactory.js:354:12
    at Hook.eval [as callAsync] (eval at create (/Users/lilja/code/umbrella/customs-data-form/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:18:1)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
make: *** [serve] Error 1

Code

vue.config.js
const SentryWebpackPlugin = require("@sentry/webpack-plugin");
const {gitDescribeSync} = require('git-describe');
const urls = {
    "development": "http://localhost:8000",
    "stage": "....",
    "production": "....",
};
const funnelBaseURLPrefix = {
    "development": "http://local.",
    "stage": "https://master.stage.",
    "production": "https://",
};
const gitSha = gitDescribeSync(__dirname, {
    longSemver: true,
    dirtySemver: true
})
const built = new Date().toISOString().replace('T', ' ')

process.env.VUE_APP_GIT_HASH = `SHA: ${gitSha.hash}, dirty: ${gitSha.dirty}, built: ${built}`

process.env.VUE_APP_CONNECTOR_WEB_API_URL = urls[process.env.NODE_ENV]
process.env.VUE_APP_BASE_URL = `${funnelBaseURLPrefix[process.env.NODE_ENV]}funnel.io`

let plugins = []
let publicPath = '/';

if (process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'stage') {
    publicPath = '/data-request-form/'
}
if (process.env.NODE_ENV === 'production') {
    process.env.VUE_APP_FULLSTORY_ORG = process.env.FULLSTORY_ORG
    plugins = []
}


module.exports = {
    chainWebpack: config => {
        config
            .plugin('html')
            .tap(args => {
                args[0].title = "Data Request Form";
                return args;
            })
        config.output
          .filename(`js/[name].[hash:8].js`)
          .chunkFilename(`js/[name].[hash:8].js`)
    },
    configureWebpack: {
        devServer: {
          headers: { "Access-Control-Allow-Origin": "*" }
        },
        plugins
    },
    devServer: {
      disableHostCheck: true,
    },
    publicPath: publicPath
}

How Do We Reproduce?

Don't know.

@alexander-akait
Copy link
Member

I recommend to create minimum reproducible test repo when you use boilerplates, because it is hard to debug

@MAkerboom
Copy link

MAkerboom commented Jan 19, 2021

I got the same on my react PWA after updating all packages:

Starting the development server...

/home/maarten/akerboom.app/node_modules/react-scripts/scripts/start.js:19
  throw err;
  ^

TypeError: Cannot read property 'split' of undefined
    at processModule (/home/maarten/akerboom.app/node_modules/eslint-webpack-plugin/dist/index.js:93:38)
    at SyncHook.eval [as call] (eval at create (/home/maarten/akerboom.app/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:7:1)
    at SyncHook.lazyCompileHook (/home/maarten/akerboom.app/node_modules/tapable/lib/Hook.js:154:20)
    at module.build.error (/home/maarten/akerboom.app/node_modules/webpack/lib/Compilation.js:781:30)
    at MultiModule.build (/home/maarten/akerboom.app/node_modules/webpack/lib/MultiModule.js:39:10)
    at Compilation.buildModule (/home/maarten/akerboom.app/node_modules/webpack/lib/Compilation.js:739:10)
    at moduleFactory.create (/home/maarten/akerboom.app/node_modules/webpack/lib/Compilation.js:1111:12)
    at MultiModuleFactory.create (/home/maarten/akerboom.app/node_modules/webpack/lib/MultiModuleFactory.js:18:3)
    at semaphore.acquire (/home/maarten/akerboom.app/node_modules/webpack/lib/Compilation.js:1063:18)
    at Semaphore.acquire (/home/maarten/akerboom.app/node_modules/webpack/lib/util/Semaphore.js:29:4)

@mmmulani
Copy link

this change seems to be breaking it: v2.4.1...v2.4.2#diff-bfe9874d239014961b1ae4e89875a6155667db834a410aaaa2ebe3cf89820556

previously it checked if module.resource was nonnull before continuing.

@mmmulani
Copy link

you can work around this locally by setting a selective version resolution: https://classic.yarnpkg.com/en/docs/selective-version-resolutions/ (I set it to 2.4.1 until this issue gets resolved)

@alexander-akait
Copy link
Member

/cc @ricardogobbosouza regression 😞

@jakewhiteley
Copy link

Came here to say this. Just spent the last 20 minutes checking through my commits today under the impression I had broken my build process. At least we picked it up quicky!

@ankon
Copy link

ankon commented Jan 19, 2021

Same thing here, the module in question is:

RawModule {
    dependencies: [],
    blocks: [],
    variables: [],
    type: 'javascript/dynamic',
    context: null,
    debugId: 2554,
    hash: undefined,
    renderedHash: undefined,
    resolveOptions: {},
    factoryMeta: {},
    warnings: [],
    errors: [],
    buildMeta: {},
    buildInfo: { cacheable: true },
    reasons: [
      ModuleReason {
        module: [NormalModule],
        dependency: [CommonJsRequireDependency],
        explanation: undefined,
        _chunks: null
      }
    ],
    _chunks: SortableSet(0) [Set] {
      _sortFn: [Function: sortById],
      _lastActiveSortFn: null,
      _cache: undefined,
      _cacheOrderIndependent: undefined
    },
    id: null,
    index: null,
    index2: null,
    depth: null,
    issuer: NormalModule {
      dependencies: [
        [CommonJsRequireDependency],
        [RequireHeaderDependency],
        [CommonJsRequireDependency],
        [RequireHeaderDependency]
      ],
      blocks: [],
      variables: [ [DependenciesBlockVariable] ],
      type: 'javascript/auto',
      context: '[redacted]/node_modules/intl',
      debugId: 2362,
      hash: undefined,
      renderedHash: undefined,
      resolveOptions: {},
      factoryMeta: {},
      warnings: [],
      errors: [],
      buildMeta: {},
      buildInfo: {
        cacheable: true,
        fileDependencies: [Set],
        contextDependencies: Set(0) {},
        assets: undefined,
        assetsInfo: undefined
      },
      reasons: [ [ModuleReason] ],
      _chunks: SortableSet(0) [Set] {
        _sortFn: [Function: sortById],
        _lastActiveSortFn: null,
        _cache: undefined,
        _cacheOrderIndependent: undefined
      },
      id: null,
      index: null,
      index2: null,
      depth: null,
      issuer: NormalModule {
        dependencies: [Array],
        blocks: [],
        variables: [],
        type: 'javascript/auto',
        context: '[redacted]/node_modules/react-intl-universal/lib',
        debugId: 1975,
        hash: undefined,
        renderedHash: undefined,
        resolveOptions: {},
        factoryMeta: {},
        warnings: [],
        errors: [],
        buildMeta: {},
        buildInfo: [Object],
        reasons: [Array],
        _chunks: [SortableSet [Set]],
        id: null,
        index: null,
        index2: null,
        depth: null,
        issuer: [NormalModule],
        profile: undefined,
        prefetched: false,
        built: true,
        used: null,
        usedExports: null,
        optimizationBailout: [],
        _rewriteChunkInReasons: undefined,
        useSourceMap: true,
        _source: [SourceMapSource],
        request: '[redacted]/node_modules/babel-loader/lib/index.js??ref--5-oneOf-3![redacted]/node_modules/react-intl-universal/lib/index.js',
        userRequest: '[redacted]/node_modules/react-intl-universal/lib/index.js',
        rawRequest: 'react-intl-universal',
        binary: false,
        parser: [Parser],
        generator: JavascriptGenerator {},
        resource: '[redacted]/node_modules/react-intl-universal/lib/index.js',
        matchResource: undefined,
        loaders: [Array],
        error: null,
        _sourceSize: null,
        _buildHash: 'f167f93bacefe0323eb191a62512a4a3',
        buildTimestamp: 1611061668395,
        _cachedSources: Map(0) {},
        lineToLine: false,
        _lastSuccessfulBuildMeta: {},
        _ast: null
      },
      profile: undefined,
      prefetched: false,
      built: true,
      used: null,
      usedExports: null,
      optimizationBailout: [],
      _rewriteChunkInReasons: undefined,
      useSourceMap: true,
      _source: SourceMapSource {
        _value: '// Expose `IntlPolyfill` as global to add locale data into runtime later on.\n' +
          "global.IntlPolyfill = require('./lib/core.js'); // Require all locale data for `Intl`. This module will be\n" +
          '// ignored when bundling for the browser with Browserify/Webpack.\n' +
          '\n' +
          "require('./locale-data/complete.js'); // hack to export the polyfill as global Intl if needed\n" +
          '\n' +
          '\n' +
          'if (!global.Intl) {\n' +
          '  global.Intl = global.IntlPolyfill;\n' +
          '\n' +
          '  global.IntlPolyfill.__applyLocaleSensitivePrototypes();\n' +
          '} // providing an idiomatic api for the nodejs version of this module\n' +
          '\n' +
          '\n' +
          'module.exports = global.IntlPolyfill;',
        _name: '[redacted]/node_modules/babel-loader/lib/index.js??ref--5-oneOf-3![redacted]/node_modules/intl/index.js',
        _sourceMap: [Object],
        _originalSource: undefined,
        _innerSourceMap: undefined,
        _removeOriginalSource: undefined
      },
      request: '[redacted]/node_modules/babel-loader/lib/index.js??ref--5-oneOf-3![redacted]/node_modules/intl/index.js',
      userRequest: '[redacted]/node_modules/intl/index.js',
      rawRequest: 'intl',
      binary: false,
      parser: Parser {
        _pluginCompat: [SyncBailHook],
        hooks: [Object],
        options: [Object],
        sourceType: 'auto',
        scope: undefined,
        state: undefined,
        comments: undefined
      },
      generator: JavascriptGenerator {},
      resource: '[redacted]/node_modules/intl/index.js',
      matchResource: undefined,
      loaders: [ [Object] ],
      error: null,
      _sourceSize: null,
      _buildHash: '2de9d4787a1c73d8f9739e895b840935',
      buildTimestamp: 1611061670091,
      _cachedSources: Map(0) {},
      lineToLine: false,
      _lastSuccessfulBuildMeta: {},
      _ast: null
    },
    profile: undefined,
    prefetched: false,
    built: true,
    used: null,
    usedExports: null,
    optimizationBailout: [],
    _rewriteChunkInReasons: undefined,
    useSourceMap: true,
    _source: null,
    sourceStr: '/* (ignored) */',
    identifierStr: 'ignored [redacted]/node_modules/intl ./locale-data/complete.js',
    readableIdentifierStr: './locale-data/complete.js (ignored)'
  }

intl's package.json has these entries for these files: https://github.com/andyearnshaw/Intl.js/blob/0958dc1ad8153f1056653ea22b8208f0df289a4e/package.json#L9-L16 -- related?

@alexander-akait
Copy link
Member

Easy to fix: https://github.com/webpack-contrib/eslint-webpack-plugin/blob/master/src/index.js#L83

if (module.resource) {
  const file = module.resource.split('?')[0];

  if (
  file &&
  micromatch.isMatch(file, wanted) &&
  !micromatch.isMatch(file, exclude)
  ) {
    // Queue file for linting.
    lint(file);
  }
}

@alexander-akait alexander-akait mentioned this issue Jan 19, 2021
6 tasks
iyolee pushed a commit to iyolee/eslint-webpack-plugin that referenced this issue Jan 19, 2021
@ricardogobbosouza
Copy link
Collaborator

@alexander-akait fixed #63

@hcklawrence
Copy link

same problem happened in MacOS, even just create a new react app using create-react-app. It should be a bug in the latest version.

@chozzz
Copy link

chozzz commented Jan 19, 2021

Same problem happened in Ubuntu - and this happened just recently. Not sure what happened, I just reinstalled my node_modules without tweaking the package.json configuration.

TypeError: Cannot read property 'split' of undefined
    at processModule (/home/choz/dev/projects/helos-fe/node_modules/eslint-webpack-plugin/dist/index.js:97:38)
    at SyncHook.eval [as call] (eval at create (/home/choz/dev/projects/helos-fe/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:5:1)
    at /home/choz/dev/projects/helos-fe/node_modules/webpack/lib/Compilation.js:781:30
    at RawModule.build (/home/choz/dev/projects/helos-fe/node_modules/webpack/lib/RawModule.js:41:3)
    at Compilation.buildModule (/home/choz/dev/projects/helos-fe/node_modules/webpack/lib/Compilation.js:739:10)

And it comes from

RawModule {
  dependencies: [],
  blocks: [],
  variables: [],
  type: 'javascript/dynamic',
  context: null,
  debugId: 2941,
  hash: undefined,
  renderedHash: undefined,
  resolveOptions: {},
  factoryMeta: {},
  warnings: [],
  errors: [],
  buildMeta: {},
  buildInfo: { cacheable: true },
  reasons: [
    ModuleReason {
      module: [NormalModule],
      dependency: [CommonJsRequireDependency],
      explanation: undefined,
      _chunks: null
    }
  ],
  _chunks: SortableSet [Set] {
    _sortFn: [Function: sortById],
    _lastActiveSortFn: null,
    _cache: undefined,
    _cacheOrderIndependent: undefined
  },
  id: null,
  index: null,
  index2: null,
  depth: null,
  issuer: NormalModule {
    dependencies: [
      [CommonJsRequireDependency],
      [RequireHeaderDependency],
      [ConstDependency]
    ],
    blocks: [],
    variables: [ [DependenciesBlockVariable] ],
    type: 'javascript/auto',
    context: '/home/choz/dev/projects/helos-fe/node_modules/create-ecdh/node_modules/bn.js/lib',
    debugId: 2839,
    hash: undefined,
    renderedHash: undefined,
    resolveOptions: {},
    factoryMeta: {},
    warnings: [],
    errors: [],
    buildMeta: {},
    buildInfo: {
      cacheable: true,
      fileDependencies: [Set],
      contextDependencies: Set {},
      assets: undefined,
      assetsInfo: undefined
    },
    reasons: [ [ModuleReason] ],
    _chunks: SortableSet [Set] {
      _sortFn: [Function: sortById],
      _lastActiveSortFn: null,
      _cache: undefined,
      _cacheOrderIndependent: undefined
    },
    id: null,
    index: null,
    index2: null,
    depth: null,
    issuer: NormalModule {
      dependencies: [Array],
      blocks: [],
      variables: [Array],
      type: 'javascript/auto',
      context: '/home/choz/dev/projects/helos-fe/node_modules/create-ecdh',
      debugId: 2649,
      hash: undefined,
      renderedHash: undefined,
      resolveOptions: {},
      factoryMeta: {},
      warnings: [],
      errors: [],
      buildMeta: {},
      buildInfo: [Object],
      reasons: [Array],
      _chunks: [SortableSet [Set]],
      id: null,
      index: null,
      index2: null,
      depth: null,
      issuer: [NormalModule],
      profile: undefined,
      prefetched: false,
      built: true,
      used: null,
      usedExports: null,
      optimizationBailout: [],
      _rewriteChunkInReasons: undefined,
      useSourceMap: false,
      _source: [OriginalSource],
      request: '/home/choz/dev/projects/helos-fe/node_modules/babel-loader/lib/index.js??ref--5-oneOf-3!/home/choz/dev/projects/helos-fe/node_modules/create-ecdh/browser.js',
      userRequest: '/home/choz/dev/projects/helos-fe/node_modules/create-ecdh/browser.js',
      rawRequest: 'create-ecdh',
      binary: false,
      parser: [Parser],
      generator: JavascriptGenerator {},
      resource: '/home/choz/dev/projects/helos-fe/node_modules/create-ecdh/browser.js',
      matchResource: undefined,
      loaders: [Array],
      error: null,
      _sourceSize: null,
      _buildHash: 'fccb2d11efd7bf391eac125adb2248f7',
      buildTimestamp: 1611063370092,
      _cachedSources: Map {},
      lineToLine: false,
      _lastSuccessfulBuildMeta: {},
      _ast: null
    },

@iyolee
Copy link

iyolee commented Jan 19, 2021

const file = (module.resource || '').split('?')[0];

if (
  file &&
  micromatch.isMatch(file, wanted) &&
  !micromatch.isMatch(file, exclude)
) {
  // Queue file for linting.
  lint(file);
}

@vadi-toptal
Copy link

Seems fixed in 2.4.3 - thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet