Skip to content

Commit dcd799d

Browse files
committed
es modules import now
1 parent 7e3345a commit dcd799d

File tree

12 files changed

+980
-272
lines changed

12 files changed

+980
-272
lines changed

scripts/build.sh

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,4 @@
1-
#!/usr/bin/env bash
2-
3-
set -e
4-
5-
cd src
6-
7-
# install JS dependencies
8-
cd js
9-
10-
yarn --ignore-engines
11-
yarn setup
12-
13-
cd ../
14-
15-
# clean up possible old install
16-
if [ -d "py/idom/static" ]; then
17-
rm -rf py/idom/static
18-
fi
19-
mkdir py/idom/static
20-
21-
# build js packages
22-
cd js
23-
npm run build
24-
cd ../
25-
26-
# copy built files to py
27-
cp -r js/packages/idom-jupyter-widget-hook/build py/idom/static/jupyter-widget
28-
cp -r js/packages/idom-simple-client/build py/idom/static/simple-client
29-
30-
cd ../
31-
32-
cd ../
1+
#!/bin/bash
2+
cd src/idom/client
3+
npm install --save-dev snowpack
4+
npx snowpack

setup.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from setuptools import setup, find_packages
44
from distutils.command.build import build # type: ignore
55
from distutils.command.sdist import sdist # type: ignore
6-
from setuptools.command.develop import develop # type: ignore
6+
from setuptools.command.develop import develop
77
import os
88
import sys
99
import subprocess
@@ -13,7 +13,7 @@
1313

1414
# basic paths used to gather files
1515
here = os.path.abspath(os.path.dirname(__file__))
16-
root = os.path.join(here, "src", "py", name)
16+
root = os.path.join(here, "src", name)
1717

1818

1919
# -----------------------------------------------------------------------------
@@ -24,8 +24,8 @@
2424
package = {
2525
"name": name,
2626
"python_requires": ">=3.6,<4.0",
27-
"packages": find_packages("src/py", exclude=["tests*"]),
28-
"package_dir": {"": "src/py"},
27+
"packages": find_packages("src", exclude=["tests*"]),
28+
"package_dir": {"": "src"},
2929
"description": "Control the web with Python",
3030
"author": "Ryan Morshead",
3131
"author_email": "ryan.morshead@gmail.com",
@@ -51,7 +51,7 @@
5151
package["install_requires"] = requirements
5252

5353
_current_extra_section = None
54-
extra_requirements = {"all": []}
54+
extra_requirements = {"all": []} # type: ignore
5555
extra_requirements_path = os.path.join(here, "requirements", "extras.txt")
5656
with open(extra_requirements_path, "r") as f:
5757
for line in map(str.strip, f):

src/idom/client/.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
js/node_modules
2-
js/web_modules
1+
node_modules
2+
web_modules

src/idom/client/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from pathlib import Path
2+
3+
4+
CLIENT_DIR = Path(__file__).parent

src/idom/client/html/simple-view.html

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
<!DOCTYPE html>
22
<html lang="en">
3-
<head><title>Snowpack - Simple Example</title></head>
3+
<head>
4+
<meta charset="utf-8"/>
5+
<title>Snowpack - Simple Example</title>
6+
</head>
47
<body>
58
<div id="app"></div>
69
<script type="module">
7-
import React from "../js/web_modules/react.js";
8-
import ReactDOM from "../js/web_modules/react-dom";
10+
import React from "../web_modules/react.js";
11+
import ReactDOM from "../web_modules/react-dom.js";
912
import Layout from "../js/index.js";
1013

1114
const uri = document.location.hostname + ":" + document.location.port;
12-
const url = (uri + document.location.pathname).split("/").slice(0, -1);
15+
const url = (uri + document.location.pathname).split("/").slice(0, -2);
1316
url[url.length - 1] = "stream";
1417
const secure = document.location.protocol === "https:";
1518

@@ -21,7 +24,7 @@
2124
}
2225
let endpoint = protocol + "//" + url.join("/");
2326

24-
const mount = document.getElementById("root");
27+
const mount = document.getElementById("app");
2528
ReactDOM.render(React.createElement(Layout, {"endpoint": endpoint}), mount);
2629
</script>
2730
</body>

src/idom/client/js/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import React, {
44
useState,
55
useMemo,
66
Suspense
7-
} from "./web_modules/react.js";
8-
import htm from './web_modules/htm.js'
7+
} from "../web_modules/react.js";
8+
import htm from '../web_modules/htm.js'
99
import serializeEvent from "./event-to-object.js";
1010

1111
const html = htm.bind(React.createElement);

0 commit comments

Comments
 (0)