jest-raw-loader icon indicating copy to clipboard operation
jest-raw-loader copied to clipboard

Compatibility with Jest 28

Open thet opened this issue 3 years ago • 11 comments

Breaks compatibility with Jest < 27, most probably (Didn't test that).

thet avatar Apr 29 '22 16:04 thet

Breaks compatibility with Jest < 27

No, Jest 27 supported both strings and an object:

type TransformedSource =
  | {code: string; map?: RawSourceMap | string | null}
  | string;

While Jest 28 only dropped support for the raw string:

type TransformedSource = {
  code: string;
  map?: RawSourceMap | string | null;
};
  • https://jestjs.io/docs/27.x/code-transformation
  • https://jestjs.io/docs/code-transformation

Therefore this isn't a breaking change for Jest 27 users. @keplersj I hope to see this merged soon.

fregante avatar May 03 '22 06:05 fregante

Btw, I currently solve it like so... in jest.config.js:

module.exports = {
    ...
    transform: {
        "^.+\\.[t|j]sx?$": "babel-jest",
        "\\.(html|xml|svg)$": "<rootDir>/jest-raw-loader.js",
    },
};

in in jest-raw-loader.js:

// jest-raw-loader compatibility with Jest version 28.
// See: https://github.com/keplersj/jest-raw-loader/pull/239
module.exports = {
    process: (content) => {
        return {
            code: "module.exports = " + JSON.stringify(content),
        };
    },
};

thet avatar May 03 '22 07:05 thet

Indeed it's easier to just drop the dependency

fregante avatar May 03 '22 07:05 fregante

Without this merged people will be abandoning this package and just do the copy/paste fix in their project:

  • https://github.com/keplersj/jest-raw-loader/pull/239#issuecomment-1115799205

glensc avatar Jul 22 '22 10:07 glensc

perhaps merge and release this with 2.0.0 version already?

  • https://github.com/keplersj/jest-raw-loader/issues/249#issuecomment-1254915136

glensc avatar Sep 22 '22 11:09 glensc

this also works:

yarn add --dev keplersj/jest-raw-loader#pull/239/head

refs:

  • https://stackoverflow.com/questions/33181297/npm-install-from-github-pull-request

glensc avatar Sep 22 '22 11:09 glensc

jest was bumped in f77f13b1, 98ecf9a5, e70ca623, dfc5fc82. I guess the CI doesn't actually test that the loader works and merges with broken deps.

glensc avatar Nov 23 '22 14:11 glensc

Merged this to my fork:

  • https://github.com/glensc/jest-raw-loader/commit/e7da211d8e02a31d7059e4fde39154080d96cae2

I plan to release it in npm. stay tuned.

glensc avatar Nov 23 '22 14:11 glensc

Published as @glen/[email protected]

glensc avatar Nov 23 '22 15:11 glensc