Skip to content

Commit 245828c

Browse files
committed
refactor!: import macro version from quansync/macro
1 parent cb1f8b4 commit 245828c

File tree

7 files changed

+36
-36
lines changed

7 files changed

+36
-36
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
"prepublishOnly": "pnpm run build"
7171
},
7272
"peerDependencies": {
73-
"quansync": ">=0.1.0"
73+
"quansync": ">=0.2.0"
7474
},
7575
"dependencies": {
7676
"ast-kit": "^1.4.0",
@@ -88,7 +88,7 @@
8888
"eslint": "^9.21.0",
8989
"oxc-transform": "^0.52.0",
9090
"prettier": "^3.5.2",
91-
"quansync": "^0.1.0",
91+
"quansync": "^0.2.0",
9292
"tsdown": "^0.6.0",
9393
"tsx": "^4.19.3",
9494
"typescript": "^5.7.3",

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export function transformQuansync(
3232
}
3333

3434
const macroName = Object.values(imports).find(
35-
(i) => i.source === 'quansync' && i.imported === 'quansyncMacro',
35+
(i) => i.source === 'quansync/macro' && i.imported === 'quansync',
3636
)?.local
3737
if (!macroName) return
3838

tests/__snapshots__/transform.test.ts.snap

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
exports[`transform > ./fixtures/alias.js 1`] = `
44
"// @ts-check
5-
import { quansync, quansyncMacro as x } from 'quansync'
5+
import { quansync as x } from 'quansync/macro'
66
import { expect } from 'vitest'
77
8-
export const echo = quansync({
8+
export const echo = x({
99
sync: /** @param {string} v */ (v) => v,
1010
async: (v) => Promise.resolve(v),
1111
})
@@ -31,49 +31,49 @@ export default async () => {
3131
3232
exports[`transform > ./fixtures/basic.js 1`] = `
3333
"// @ts-check
34-
import { quansyncMacro } from 'quansync'
34+
import { quansync } from 'quansync/macro'
3535
import { expect } from 'vitest'
3636
37-
export const getNumber = quansyncMacro({
37+
export const getNumber = quansync({
3838
sync: /** @param {number} id */ (id) => id,
3939
async: (id) => Promise.resolve(id),
4040
})
4141
42-
const inc1 = quansyncMacro(function* (){
42+
const inc1 = quansync(function* (){
4343
const value = yield getNumber(1)
4444
return value + 1
4545
})
4646
47-
const inc2 = quansyncMacro(function* (id) {
47+
const inc2 = quansync(function* (id) {
4848
const value = yield getNumber(1)
4949
return value + 1
5050
})
5151
52-
const inc3 = quansyncMacro(function* named(){
52+
const inc3 = quansync(function* named(){
5353
const value = yield getNumber(1)
5454
return value + 1
5555
})
5656
57-
const inc4 = quansyncMacro(function* named(id) {
57+
const inc4 = quansync(function* named(id) {
5858
const value = yield getNumber(1)
5959
return value + 1
6060
})
6161
62-
const inc5 = quansyncMacro(() => {
62+
const inc5 = quansync(() => {
6363
return function* () {
6464
const value = yield getNumber(1)
6565
return value + 1
6666
}.call(this)
6767
})
6868
69-
const inc6 = quansyncMacro((id) => {
69+
const inc6 = quansync((id) => {
7070
return function* () {
7171
const value = yield getNumber(1)
7272
return value + 1
7373
}.call(this)
7474
})
7575
76-
export const fn7 = quansyncMacro(() => {
76+
export const fn7 = quansync(() => {
7777
return function* () {
7878
yield 1
7979
yield 2
@@ -107,15 +107,15 @@ export default async () => {
107107
108108
exports[`transform > ./fixtures/inlined-arrow.js 1`] = `
109109
"// @ts-check
110-
import { quansyncMacro } from 'quansync'
110+
import { quansync } from 'quansync/macro'
111111
import { expect } from 'vitest'
112112
113-
export const echo = quansyncMacro({
113+
export const echo = quansync({
114114
sync: /** @param {string} v */ (v) => v,
115115
async: (v) => Promise.resolve(v),
116116
})
117117
118-
const echoNewLine = quansyncMacro(
118+
const echoNewLine = quansync(
119119
/** @param {string|Promise<string>} v */ (v) =>
120120
{
121121
return function* () {

tests/fixtures/alias.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// @ts-check
2-
import { quansync, quansyncMacro as x } from 'quansync'
2+
import { quansync as x } from 'quansync/macro'
33
import { expect } from 'vitest'
44

5-
export const echo = quansync({
5+
export const echo = x({
66
sync: /** @param {string} v */ (v) => v,
77
async: (v) => Promise.resolve(v),
88
})

tests/fixtures/basic.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
// @ts-check
2-
import { quansyncMacro } from 'quansync'
2+
import { quansync } from 'quansync/macro'
33
import { expect } from 'vitest'
44

5-
export const getNumber = quansyncMacro({
5+
export const getNumber = quansync({
66
sync: /** @param {number} id */ (id) => id,
77
async: (id) => Promise.resolve(id),
88
})
99

10-
const inc1 = quansyncMacro(async function () {
10+
const inc1 = quansync(async function () {
1111
const value = await getNumber(1)
1212
return value + 1
1313
})
1414

15-
const inc2 = quansyncMacro(async function (id) {
15+
const inc2 = quansync(async function (id) {
1616
const value = await getNumber(1)
1717
return value + 1
1818
})
1919

20-
const inc3 = quansyncMacro(async function named() {
20+
const inc3 = quansync(async function named() {
2121
const value = await getNumber(1)
2222
return value + 1
2323
})
2424

25-
const inc4 = quansyncMacro(async function named(id) {
25+
const inc4 = quansync(async function named(id) {
2626
const value = await getNumber(1)
2727
return value + 1
2828
})
2929

30-
const inc5 = quansyncMacro(async () => {
30+
const inc5 = quansync(async () => {
3131
const value = await getNumber(1)
3232
return value + 1
3333
})
3434

35-
const inc6 = quansyncMacro(async (id) => {
35+
const inc6 = quansync(async (id) => {
3636
const value = await getNumber(1)
3737
return value + 1
3838
})
3939

40-
export const fn7 = quansyncMacro(async () => {
40+
export const fn7 = quansync(async () => {
4141
await 1
4242
await 2
4343
const fn = async () => {

tests/fixtures/inlined-arrow.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// @ts-check
2-
import { quansyncMacro } from 'quansync'
2+
import { quansync } from 'quansync/macro'
33
import { expect } from 'vitest'
44

5-
export const echo = quansyncMacro({
5+
export const echo = quansync({
66
sync: /** @param {string} v */ (v) => v,
77
async: (v) => Promise.resolve(v),
88
})
99

10-
const echoNewLine = quansyncMacro(
10+
const echoNewLine = quansync(
1111
/** @param {string|Promise<string>} v */ async (v) =>
1212
(await echo(await v)) + '\n',
1313
)

0 commit comments

Comments
 (0)