Skip to content

Commit

Permalink
fix(core): enforce sourcemap: 'inline' for jest (#695)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brooooooklyn authored Feb 15, 2023
1 parent 860d1f6 commit 2439b7e
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
3 changes: 1 addition & 2 deletions packages/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export interface Options {
function transformOption(path: string, options?: Options, jest = false): SwcOptions {
const opts = options == null ? {} : options
opts.esModuleInterop = opts.esModuleInterop ?? true
const sourceMapDefault = jest ? 'inline' : true
return {
filename: path,
jsc: {
Expand Down Expand Up @@ -59,7 +58,7 @@ function transformOption(path: string, options?: Options, jest = false): SwcOpti
type: options?.module ?? 'commonjs',
noInterop: !opts.esModuleInterop,
},
sourceMaps: typeof opts.sourcemap === 'undefined' ? sourceMapDefault : opts.sourcemap,
sourceMaps: jest || typeof opts.sourcemap === 'undefined' ? 'inline' : opts.sourcemap,
inlineSourcesContent: true,
swcrc: false,
...(options?.swc ?? {}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ Generated by [AVA](https://avajs.dev).
`"use strict";␊
const Button = ({ text })=>/*#__PURE__*/ h("div", null, text);␊
`
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHN4Il0sInNvdXJjZXNDb250ZW50IjpbIlxuICBjb25zdCBCdXR0b24gPSAoeyB0ZXh0IH0pID0+IChcbiAgICA8ZGl2PlxuICAgICAge3RleHR9XG4gICAgPC9kaXY+XG4gIClcbiJdLCJuYW1lcyI6WyJCdXR0b24iLCJ0ZXh0IiwiZGl2Il0sIm1hcHBpbmdzIjoiO0FBQ0UsTUFBTUEsU0FBUyxDQUFDLEVBQUVDLEtBQUksRUFBRSxpQkFDdEIsRUFBQ0MsYUFDRUQifQ==`

## should transform jsx into new jsx runtime

Expand All @@ -24,4 +25,5 @@ Generated by [AVA](https://avajs.dev).
const Button = ({ text })=>/*#__PURE__*/ (0, _jsxRuntime.jsx)("div", {␊
children: text␊
});␊
`
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHN4Il0sInNvdXJjZXNDb250ZW50IjpbIlxuICBjb25zdCBCdXR0b24gPSAoeyB0ZXh0IH0pID0+IChcbiAgICA8ZGl2PlxuICAgICAge3RleHR9XG4gICAgPC9kaXY+XG4gIClcbiJdLCJuYW1lcyI6WyJCdXR0b24iLCJ0ZXh0IiwiZGl2Il0sIm1hcHBpbmdzIjoiOzs7OztBQUNFLE1BQU1BLFNBQVMsQ0FBQyxFQUFFQyxLQUFJLEVBQUUsaUJBQ3RCLHFCQUFDQztrQkFDRUQifQ==`
Binary file not shown.
3 changes: 2 additions & 1 deletion packages/jest/__test__/hoist-top-level.spec.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ Generated by [AVA](https://avajs.dev).
console.log(bar);␊
jest.unmock('./bar/foo').dontMock('./bar/bar');␊
};␊
`
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImplc3Quc3BlYy50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJcbmNvbnN0IGZvbyA9ICdmb28nXG5jb25zb2xlLmxvZyhmb28pXG5qZXN0LmVuYWJsZUF1dG9tb2NrKClcbmplc3QuZGlzYWJsZUF1dG9tb2NrKClcbmplc3QubW9jaygnLi9mb28nKVxuamVzdC5tb2NrKCcuL2Zvby9iYXInLCAoKSA9PiAnYmFyJylcbmplc3QudW5tb2NrKCcuL2Jhci9mb28nKS5kb250TW9jaygnLi9iYXIvYmFyJylcbmplc3QuZGVlcFVubW9jaygnLi9mb28nKVxuamVzdC5tb2NrKCcuL2ZvbycpLm1vY2soJy4vYmFyJylcbmNvbnN0IGZ1bmMgPSAoKSA9PiB7XG4gIGNvbnN0IGJhciA9ICdiYXInXG4gIGNvbnNvbGUub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M7QUFSeEIsTUFBTUUsTUFBTTtBQUNaQyxRQUFRQyxHQUFHLENBQUNGO0FBS1pMLEtBQUtRLE1BQU0sQ0FBQyxhQUFhQyxRQUFRLENBQUM7QUFHbEMsTUFBTUMsT0FBTyxJQUFNO0lBR2pCVixLQUFLUSxNQUFNLENBQUM7SUFDWlIsS0FBS0csSUFBSSxDQUFDO0lBQ1ZILEtBQUtHLElBQUksQ0FBQyxhQUFhLElBQU07SUFDN0JILEtBQUtRLE1BQU0sQ0FBQztJQUVaUixLQUFLSSxVQUFVLENBQUM7SUFDaEJKLEtBQUtHLElBQUksQ0FBQyxTQUFTQSxJQUFJLENBQUM7SUFSeEIsTUFBTVEsTUFBTTtJQUNaTCxRQUFRQyxHQUFHLENBQUNJO0lBS1pYLEtBQUtRLE1BQU0sQ0FBQyxhQUFhQyxRQUFRLENBQUM7QUFHcEM7QUFDQSxNQUFNRyxRQUFRLElBQU07SUFHbEJaLEtBQUtHLElBQUksQ0FBQztJQUNWSCxLQUFLUSxNQUFNLENBQUM7SUFDWlIsS0FBS0csSUFBSSxDQUFDLGFBQWEsSUFBTTtJQUM3QkgsS0FBS1EsTUFBTSxDQUFDO0lBRVpSLEtBQUtJLFVBQVUsQ0FBQztJQUNoQkosS0FBS0csSUFBSSxDQUFDLFNBQVNBLElBQUksQ0FBQztJQVJ4QixNQUFNUSxNQUFNO0lBQ1pMLFFBQVFDLEdBQUcsQ0FBQ0k7SUFLWlgsS0FBS1EsTUFBTSxDQUFDLGFBQWFDLFFBQVEsQ0FBQztBQUdwQyJ9`
Binary file modified packages/jest/__test__/hoist-top-level.spec.ts.snap
Binary file not shown.

0 comments on commit 2439b7e

Please sign in to comment.