Skip to content

Commit a2e9203

Browse files
authored
feat: add http-import example (#284)
1 parent e2636db commit a2e9203

File tree

7 files changed

+76
-3
lines changed

7 files changed

+76
-3
lines changed

pnpm-lock.yaml

Lines changed: 12 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rspack/http-import/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
http-import.lock.data/

rspack/http-import/http-import.lock

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": 1,
3+
"entries": {
4+
"https://www.unpkg.com/the-answer": {
5+
"resolved": "https://www.unpkg.com/the-answer",
6+
"integrity": "sha512-qy9ndp7bPncf/DMQ94Gl5JsOGkabSNUdloOFyy5J70PaB3kWjpylAUWtK3wuxNlvbgP9z4tF0tHxlrhuXRKZAQ==",
7+
"content_type": "text/javascript; charset=utf-8",
8+
"valid_until": 1777431035228,
9+
"etag": null
10+
}
11+
}
12+
}

rspack/http-import/index.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Document</title>
8+
</head>
9+
<body>
10+
<div id="root"></div>
11+
</body>
12+
</html>

rspack/http-import/package.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "example-http-import",
3+
"version": "1.0.0",
4+
"private": true,
5+
"license": "MIT",
6+
"sideEffects": ["**/*.css", "**/*.less", "**/*.scss"],
7+
"main": "index.js",
8+
"scripts": {
9+
"build": "rspack build",
10+
"dev": "rspack serve"
11+
},
12+
"devDependencies": {
13+
"@rspack/cli": "1.3.7",
14+
"@rspack/core": "1.3.7"
15+
}
16+
}

rspack/http-import/rspack.config.mjs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// @ts-check
2+
import { rspack } from "@rspack/core";
3+
import { defineConfig } from "@rspack/cli";
4+
5+
export default defineConfig({
6+
entry: "./src/index.js",
7+
experiments: {
8+
buildHttp:{
9+
allowedUris: ['https://www.unpkg.com'],
10+
lockfileLocation: 'http-import.lock',
11+
}
12+
},
13+
plugins: [
14+
new rspack.HtmlRspackPlugin({
15+
template: "./index.html",
16+
}),
17+
],
18+
});

rspack/http-import/src/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import answer from 'https://www.unpkg.com/the-answer';
2+
function render() {
3+
document.getElementById('root').innerHTML = `the answer to the universe is ${answer}`;
4+
}
5+
render();

0 commit comments

Comments
 (0)