Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

failed to load module script #4

Open
gplanansky opened this issue Jan 7, 2024 · 0 comments
Open

failed to load module script #4

gplanansky opened this issue Jan 7, 2024 · 0 comments

Comments

@gplanansky
Copy link

gplanansky commented Jan 7, 2024

@universalmind303 I fail to import browser side, via a script invoked in index.html.

Steps to reproduce:

mkdir jspolars
cd jspolars

$ yarn add @pola-rs/browser
yarn add v1.22.21
info No lockfile found.
(node:63701) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
success Saved lockfile.
success Saved 1 new dependency.
info Direct dependencies
└─ @pola-rs/[email protected]
info All dependencies
└─ @pola-rs/[email protected]
✨  Done in 1.78s.

./index.html

<!DOCTYPE html>
<html lang="en">
  <head>
  <meta charset="UTF-8">    
  <title>pola-rs/browser</title>    
</head>

<body>
  <div id="output"></div>
  <script  type="module" src="./script.js"></script>
</body>
</html>

./script.js

import * as pl from "./node_modules/@pola-rs/browser"
let  filepath = "https://raw.githubusercontent.com/pola-rs/polars/master/examples/datasets/foods2.csv"
let response = await fetch(filepath);
let responseTEXT = await response.text();
let df = await pl.readCSV(responseTEXT);
console.table(df)

./start-http-server-8119.sh

python -m http.server --bind 127.0.0.1 8119

Start the server:

.  start-http-server-8119.sh 
Serving HTTP on 127.0.0.1 port 8119 (http://127.0.0.1:8119/) ...
127.0.0.1 - - [07/Jan/2024 08:06:35] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [07/Jan/2024 08:06:35] "GET /script.js HTTP/1.1" 200 -
127.0.0.1 - - [07/Jan/2024 08:06:35] "GET /node_modules/@pola-rs/browser/ HTTP/1.1" 200 -
127.0.0.1 - - [07/Jan/2024 08:06:35] "GET /favicon.ico HTTP/1.1" 200 -
127.0.0.1 - - [07/Jan/2024 08:09:01] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [07/Jan/2024 08:09:01] "GET /script.js HTTP/1.1" 200 -
127.0.0.1 - - [07/Jan/2024 08:09:01] "GET /node_modules/@pola-rs/browser HTTP/1.1" 301 -
127.0.0.1 - - [07/Jan/2024 08:09:01] "GET /node_modules/@pola-rs/browser/ HTTP/1.1" 200 -
127.0.0.1 - - [07/Jan/2024 08:09:01] "GET /favicon.ico HTTP/1.1" 200 -

Using import * as pl from "@pola-rs/browser" fails:
console.log:
```
localhost/:1 Uncaught TypeError: Failed to resolve module specifier "@pola-rs/browser".


Using `import * from "./node_modules/@pola-rs/browser"` fails:
console.log:

browser/:1 Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.

This just gives the directory listing.   

No joy importing browser/browser.js either.

How should I do this?   I'd like to integrate polars into a browser-side library suite.  It does not have to be perfect at this juncture, for p.o.c.,  but hoping of course for further development.

thanks, George



Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant