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

Webpack 5 and Webpacker 6 - Add note that output entry should also not be specified #466

Closed
wants to merge 1 commit into from

Conversation

Pezmc
Copy link

@Pezmc Pezmc commented Jan 27, 2021

This PR contains a:

  • bugfix
  • new feature
  • code refactor
  • test update
  • typo fix
  • metadata update

Motivation / Use-Case

I'm upgrading our app to webpacker 6 (webpack 5) and started hitting the snags discussed in #450 and #452

The fix was to add the following to the top of our karma.conf.js:

const webpackConfig = require('./config/webpack/test.js')

// karma watches the test entry points, Do NOT specify the entry option
// From https://github.com/ryanclark/karma-webpack#getting-started
delete webpackConfig.entry
delete webpackConfig.output

As well as:

  • Adding webpack to frameworks: ['jasmine', 'webpack'], (already covered in docs)
  • Adding watched: false to files { pattern: 'spec/javascripts/**/*[sS]pec.js', watched: false },

This PR just adds that note about output to the docs.

Breaking Changes

None

Additional Info

Perhaps an example karma config file for webpacker would also be of value to add to the readme?

For reference a filleted version of ours now looks like:

const webpackConfig = require('./config/webpack/test.js')

// Remove entry and output from webpacker config
// Karma watches the test entry points, do not specify entry or output option
// From https://github.com/ryanclark/karma-webpack#getting-started
delete webpackConfig.entry
delete webpackConfig.output

module.exports = (config) => {
  config.set({
    // ... normal karma configuration

    // add webpack to your list of frameworks
    frameworks: ['mocha', 'webpack'],

    plugins: ['karma-webpack', 'karma-mocha'],

    files: [
      // all files ending in ".test.js"
      // !!! use watched: false as we use webpacks watch
      { pattern: 'test/**/*.test.js', watched: false },
    ],

    preprocessors: {
      // add webpack as preprocessor
      'test/**/*.test.js': ['webpack'],
    },

    webpack: webpackConfig,

    webpackMiddleware: {
      // webpack-dev-middleware configuration
      stats: 'errors-only',
    },
  })
}

I'm upgrading our app to webpacker 6 (webpack 5) and started hitting the snags discussed in #450

The fix was to add the following to the top of our karma.conf.js:

```
const webpackConfig = require('./config/webpack/test.js')

// karma watches the test entry points, Do NOT specify the entry option
// From https://github.com/ryanclark/karma-webpack#getting-started
delete webpackConfig.entry
delete webpackConfig.output
```
@Pezmc Pezmc changed the title Add note that output entry should also not be specified Webpack 5 and Webpacker 6 - Add note that output entry should also not be specified Jan 27, 2021
@thijstriemstra
Copy link

I tried this but it didn't change the error I get with karma-webpack@next:

> karma start karma.conf.js

30 01 2021 19:30:47.627:INFO [framework.detect-browsers]: The following browsers will be used: [
  'Chrome_headless',
  'Firefox_headless',
  'Safari',
  'SafariTechPreview'
]
Webpack bundling...
assets by chunk 93.5 KiB (name: commons)
  asset commons.min.js 93.1 KiB [emitted] [minimized] (name: commons) (id hint: commons)
  asset css/commons.min.css 391 bytes [emitted] [minimized] (name: commons) (id hint: commons)
asset runtime.min.js 1.73 KiB [emitted] [minimized] (name: runtime)
asset videojs.wavesurfer.min.js 775 bytes [emitted] [minimized] (name: videojs.wavesurfer)
asset videojs.wavesurfer.spec.3357133060.min.js 761 bytes [emitted] [minimized] (name: videojs.wavesurfer.spec.3357133060)
asset fluid.spec.3609059172.min.js 638 bytes [emitted] [minimized] (name: fluid.spec.3609059172)
asset live.spec.1168012483.min.js 638 bytes [emitted] [minimized] (name: live.spec.1168012483)
asset options.spec.104896635.min.js 638 bytes [emitted] [minimized] (name: options.spec.104896635)
asset tracks.spec.3282997209.min.js 638 bytes [emitted] [minimized] (name: tracks.spec.3282997209)
asset utils.spec.4273633158.min.js 638 bytes [emitted] [minimized] (name: utils.spec.4273633158)
asset video.spec.1635427680.min.js 638 bytes [emitted] [minimized] (name: video.spec.1635427680)
asset defaults.spec.1293063665.min.js 528 bytes [emitted] [minimized] (name: defaults.spec.1293063665)
webpack 5.19.0 compiled successfully in 5732 ms
30 01 2021 19:30:54.025:ERROR [karma-server]: Error during file loading or preprocessing
TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined
    at Hash.update (internal/crypto/hash.js:82:11)
    at Object.sha1 (/Users/thijstriemstra/projects/videojs-wavesurfer/node_modules/karma/lib/utils/crypto-utils.js:9:8)
    at runProcessors (/Users/thijstriemstra/projects/videojs-wavesurfer/node_modules/karma/lib/preprocessor.js:70:26)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at FileList.preprocess [as _preprocess] (/Users/thijstriemstra/projects/videojs-wavesurfer/node_modules/karma/lib/preprocessor.js:134:5)
    at async Promise.all (index 1)
    at /Users/thijstriemstra/projects/videojs-wavesurfer/node_modules/karma/lib/file-list.js:90:11
    at async Promise.all (index 14)

@Pezmc
Copy link
Author

Pezmc commented Jan 30, 2021

Open a new issue and post your karma config file!

@codymikol
Copy link
Owner

Hey @Pezmc, thanks for the PR!

I remember reading another issue where it seems there is a certain setup where users expect the output configuration to work. I want to do a little more investigation into this to see if its something we can actually support vs something that needs to be documented.

@codymikol
Copy link
Owner

I just merged in a PR to the next branch that ensures that output will function, thank you for this contribution though!

@codymikol codymikol closed this Feb 2, 2021
@Pezmc
Copy link
Author

Pezmc commented Feb 2, 2021

@codymikol Which PR is that? I see the warning PR is that what you're referring to? #477

@Pezmc Pezmc deleted the patch-1 branch February 2, 2021 08:49
@codymikol
Copy link
Owner

That's the one, it has tests proving you can use a custom output path so long as you use the default filename. If you don't use the default name, it yells at you and sets it back to the default.

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

Successfully merging this pull request may close these issues.

None yet

3 participants