Skip to content
This repository was archived by the owner on Mar 5, 2023. It is now read-only.

Commit 5f056ab

Browse files
author
Daniel K
committed
Add failing test machine with babel macro
1 parent 1a09a31 commit 5f056ab

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import env from 'penv.macro';
2+
import { Machine } from '@xstate/compiled';
3+
4+
type LightEvent = { type: 'TIMER' };
5+
6+
interface LightContext {
7+
elapsed: number;
8+
}
9+
10+
const withMacros = Machine<LightContext, LightEvent, 'withMacros'>({
11+
initial: 'green',
12+
context: { elapsed: 0 },
13+
on: {
14+
POWER_OUTAGE: {
15+
target: '.red',
16+
},
17+
},
18+
states: {
19+
green: {
20+
on: {
21+
TIMER: env({ development: 'red' }, 'yellow'),
22+
},
23+
},
24+
yellow: {
25+
on: {
26+
TIMER: 'red',
27+
},
28+
},
29+
red: {
30+
on: {
31+
TIMER: 'green',
32+
},
33+
},
34+
},
35+
});

packages/xstate-compiled/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"@types/minimist": "^1.2.0",
3737
"@types/node": "^14.0.14",
3838
"@xstate/react": "^0.8.1",
39+
"penv.macro": "^0.4.0",
3940
"typescript": "^3.9.7",
4041
"nodemon": "2.0.4"
4142
},

yarn.lock

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@
221221
dependencies:
222222
regenerator-runtime "^0.13.4"
223223

224-
"@babel/runtime@^7.7.2":
224+
"@babel/runtime@^7.5.0", "@babel/runtime@^7.7.2":
225225
version "7.11.2"
226226
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.11.2.tgz#f549c13c754cc40b87644b9fa9f09a6a95fe0736"
227227
integrity sha512-TeWkU52so0mPtDcaCTxNBI/IHiz0pZgr8VEFqXFtZWpYD08ZB6FaSwVAS8MKRQAP3bYKiVjwysOJgMFY28o6Tw==
@@ -3004,6 +3004,13 @@ path-type@^4.0.0:
30043004
resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b"
30053005
integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==
30063006

3007+
penv.macro@^0.4.0:
3008+
version "0.4.0"
3009+
resolved "https://registry.yarnpkg.com/penv.macro/-/penv.macro-0.4.0.tgz#06e810a8234a07cb09f7a4c0819d8f88ec7d159a"
3010+
integrity sha512-rvqR3AreOAkii3ZPAiH+V4nNSk9W5bUAaT5+D9YK2dPzPmGZcFjuVyfBYmbkm979fR6gVoEfnvGMGTk4CFPskQ==
3011+
dependencies:
3012+
"@babel/runtime" "^7.5.0"
3013+
30073014
picomatch@^2.0.4, picomatch@^2.0.5, picomatch@^2.2.1, picomatch@^2.2.2:
30083015
version "2.2.2"
30093016
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad"

0 commit comments

Comments
 (0)