이 예제는 npm run build를 실행하여 만들어진 통합 ES 모듈 배포본(dist/flowchart.js)을 사용합니다.
file:///...)로 이 HTML을 직접 더블 클릭하여 열면 모듈 import가 동작하지 않고 에러가
발생합니다.npm run dev)를 구동한 상태에서 브라우저 주소창에
http://localhost:5173/test-app/example-esm.html을 입력하여 정상 동작을 확인해 주시기 바랍니다.
<canvas id="flowchartCanvasC"></canvas>
<script type="module">
import { drawFlowchart } from '../dist/flowchart.js';
const cCode = `
if (a == 1) {
print(a);
} else {
print(b);
}
`;
const canvasC = document.getElementById('flowchartCanvasC');
drawFlowchart(cCode, 'C', canvasC);
</script>
<canvas id="flowchartCanvasPython"></canvas>
<script type="module">
import { drawFlowchart } from '../dist/flowchart.js';
const pyCode = `
if a == 1:
print(a)
else:
print(b)
`;
const canvasPy = document.getElementById('flowchartCanvasPython');
drawFlowchart(pyCode, 'Python', canvasPy);
</script>