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

Commit 2c3b7de

Browse files
Daniel Kdanielkcz
authored andcommitted
Add failing test machine with babel macro
1 parent f25ffbe commit 2c3b7de

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' } | { type: 'POWER_OUTAGE' };
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/node": "^14.0.14",
3737
"@types/rimraf": "^3.0.0",
3838
"@xstate/react": "^0.8.1",
39+
"penv.macro": "^0.4.0",
3940
"nodemon": "2.0.4",
4041
"typescript": "^3.9.7"
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==
@@ -2998,6 +2998,13 @@ path-type@^4.0.0:
29982998
resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b"
29992999
integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==
30003000

3001+
penv.macro@^0.4.0:
3002+
version "0.4.0"
3003+
resolved "https://registry.yarnpkg.com/penv.macro/-/penv.macro-0.4.0.tgz#06e810a8234a07cb09f7a4c0819d8f88ec7d159a"
3004+
integrity sha512-rvqR3AreOAkii3ZPAiH+V4nNSk9W5bUAaT5+D9YK2dPzPmGZcFjuVyfBYmbkm979fR6gVoEfnvGMGTk4CFPskQ==
3005+
dependencies:
3006+
"@babel/runtime" "^7.5.0"
3007+
30013008
picomatch@^2.0.4, picomatch@^2.0.5, picomatch@^2.2.1, picomatch@^2.2.2:
30023009
version "2.2.2"
30033010
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad"

0 commit comments

Comments
 (0)