Ts-loader: Breaking change in micromatch 4 in ts-loader 5.4.6

Created on 6 May 2019  路  13Comments  路  Source: TypeStrong/ts-loader

Expected Behaviour

Everything should work fine because it is just a patch, not a breaking release.

Actual Behaviour

I am having this log when trying to upgrade to version 5.4.6

[root]\node_modules\ts-loader\node_modules\micromatch\index.js:44
    let isMatch = picomatch(String(patterns[i]), { ...options, onResult }, true);
                                                   ^^^

SyntaxError: Unexpected token ...

Steps to Reproduce the Problem

Here is my webpack.config.js

const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');

module.exports = {
  resolve: {
    extensions: ['.ts', '.js'],
    plugins: [new TsconfigPathsPlugin({})],
  },
  module: {
    rules: [
      {
        test: /\.ts$/,
        exclude: [/node_modules/],
        use: [
          {
            loader: 'ts-loader',
          },
        ],
      },
    ],
  },
};

Location of a Minimal Repository that Demonstrates the Issue.

Refer to this PR: https://github.com/penta-jelly/re-radio/pull/167

Follow these steps will produce this error

  • Checkout branch.
  • Run cd e2e
  • Run npm ci
  • Run npm run cypress:open
  • Open any test showing up in Cypress panel.
  • Then you can see the error log described above.

CI build result: https://circleci.com/gh/penta-jelly/re-radio/802

Most helpful comment

This issue should not be a problem since Cypress 3.3.0.

All 13 comments

what version of node are you running?

I've unpublished 5.4.6 - it looks like node 8 is the minimum requirement and that doesn't appear to be listed in the breaking changes: https://github.com/micromatch/micromatch/blob/bdd32f41e07f401b12ae7c8b04d22b275c88c84b/package.json#L33

Will update ts-loader to 6.0.0 and republish with the appropriate node version range

@johnnyreilly I am using node 10. Release this dependencies upgrade on version on 6.0 is fine for me, I will figure a way to solve it on my project.

Okay that's somewhat unexpected - according to micromatch the minimum is node 8. So I'm not clear why it's failing on your project.... The error message suggests that it's the { ...options that's problematic. This suggests you're running on pre node 8.6 (see https://medium.com/@adambrodziak/use-js-object-spread-operator-instead-of-object-assign-pattern-in-node-8-125a4914f6dd )

Am I right? Can you think of another reason why this would be an issue for you?

I am thinking the reason it is failed because ts-loader was ran directly on Browser (Cypress mechanism) but not on NodeJS environment. Do you have any idea about how to solve it?

I am thinking the reason it is failed because ts-loader was ran directly on Browser

I'm not sure I understand how that would work... Either way, I'd still expect object spread to be just fine since chrome has had it for a very long time indeed!

Puzzling...

@pvtri96 It is a problem in cypress not in ts-loader. Cypress comes with electron builtin with chorme 63 that does not support object spread. You should be fine after this https://github.com/cypress-io/cypress/pull/4001 gets released. What you can do is to not run your code in electron but the browser instead. You can do it like this https://docs.cypress.io/guides/guides/command-line.html#cypress-run

@B3zo0 thanks for your in-depth answer. Instead of trying to find a workaround for this, I am better stick with [email protected] while waiting for Cypress to release the new version with Chrome 73 support.

any updates on this? because with v6.0.0 it has this problem.

Without knowing your problem I can't advise in detail. Micromatch 4 is a breaking changes release and so (accordingly) ts-loader 6 is too. My advice is stick with 5.x until you're able to upgrade. That may mean waiting for a cypress release if that's what is impacting you.

This issue should not be a problem since Cypress 3.3.0.

Hi, i have this issue @6.0.3

Was this page helpful?
0 / 5 - 0 ratings