Skip to content

Commit

Permalink
subpath imports for explicit 1:1, concat prefix + suffix scenarios an…
Browse files Browse the repository at this point in the history
…d conditionals, with fixtures that verify project setup and build result with runtime
  • Loading branch information
Adam McKee committed Nov 7, 2024
1 parent ca35659 commit 2852249
Show file tree
Hide file tree
Showing 87 changed files with 1,648 additions and 481 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- uses: dtolnay/rust-toolchain@stable
- uses: swatinem/rust-cache@v2
- name: cargo test
Expand Down
33 changes: 27 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ members = [
[workspace.dependencies]
anyhow = "1.0.92"
serde = { version = "1.0.213", features = ["derive"] }
serde_json = "1.0.132"
serde_json = { version = "1.0.132", features = ["preserve_order"] }
swc = "4.0.0"
swc_common = { version = "3.0.0", features = ["concurrent"] }
swc_ecma_ast = "3.0.0"
Expand Down
4 changes: 2 additions & 2 deletions fn_build/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ repository = { workspace = true }
[dependencies]
anyhow = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
swc = { workspace = true }
swc_common = { workspace = true }
swc_ecma_ast = { workspace = true }
swc_ecma_parser = { workspace = true }
swc_ecma_visit = { workspace = true }
thiserror = "1.0.67"
thiserror = "2.0.0"
tokio = { workspace = true }

[dev-dependencies]
serde_json = { workspace = true }
temp-dir = { workspace = true }
12 changes: 12 additions & 0 deletions fn_build/fixtures/node/js/http_route/.fixture/build_debug.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"files": [
{
"path": "package.json",
"result": "identical"
},
{
"path": "routes/data/lambda.js",
"result": "identical"
}
]
}
14 changes: 14 additions & 0 deletions fn_build/fixtures/node/js/http_route/.fixture/build_release.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"files": [
{
"path": "package.json",
"result": "identical"
},
{
"path": "routes/data/lambda.js",
"result": {
"content": "export const DELETE=()=>{console.log(\"delete\")};"
}
}
]
}
13 changes: 13 additions & 0 deletions fn_build/fixtures/node/js/http_route/.fixture/parse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"dependencies": "unused",
"sources": [
{
"imports": [],
"path": "package.json"
},
{
"imports": [],
"path": "routes/data/lambda.js"
}
]
}
3 changes: 3 additions & 0 deletions fn_build/fixtures/node/js/http_route/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"files": [
{
"path": "package.json",
"result": "identical"
},
{
"path": "lib/data.js",
"result": "identical"
},
{
"path": "routes/data/lambda.js",
"result": "identical"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"files": [
{
"path": "package.json",
"result": "identical"
},
{
"path": "lib/data.js",
"result": {
"content": "let t=[];export function getData(){return t}"
}
},
{
"path": "routes/data/lambda.js",
"result": {
"content": "import{getData as o}from\"../../lib/data.js\";export const GET=()=>{console.log(\"got\",o())};"
}
}
]
}
21 changes: 21 additions & 0 deletions fn_build/fixtures/node/js/relative_import/.fixture/parse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"dependencies": "unused",
"sources": [
{
"imports": [],
"path": "package.json"
},
{
"imports": [],
"path": "lib/data.js"
},
{
"imports": [
{
"relativeSource": "lib/data.js"
}
],
"path": "routes/data/lambda.js"
}
]
}
3 changes: 3 additions & 0 deletions fn_build/fixtures/node/js/relative_import/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"files": [
{
"path": "package.json",
"result": "identical"
},
{
"path": "lib/tla-log.js",
"result": "identical"
},
{
"path": "routes/data/lambda.js",
"result": "identical"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"files": [
{
"path": "package.json",
"result": "identical"
},
{
"path": "lib/tla-log.js",
"result": {
"content": "export function getLog(){return\"log\"}"
}
},
{
"path": "routes/data/lambda.js",
"result": {
"content": "import{getData as o}from\"#data\";import{getLog as t}from\"#log\";export const GET=()=>{console[t()](\"got\",o())};"
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"dependencies": "required",
"sources": [
{
"imports": [],
"path": "package.json"
},
{
"imports": [],
"path": "lib/tla-log.js"
},
{
"imports": [
{
"packageDependency": {
"package": "data-dep",
"subpath": null
}
},
{
"relativeSource": "lib/tla-log.js"
}
],
"path": "routes/data/lambda.js"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"entrypoint": "routes/data/lambda.js"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function getData() {
return []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function getLog() {
return 'log'
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"type": "module",
"imports": {
"#data": {
"node": "data-dep",
"default": "./lib/data-polyfill.js"
},
"#log": {
"node": "./lib/tla-log.js",
"module-sync": "log-dep"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import {getData} from '#data'
import {getLog} from '#log'

export const GET = () => {
console[getLog()]('got', getData())
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"files": [
{
"path": "package.json",
"result": "identical"
},
{
"path": "routes/data/lambda.js",
"result": "identical"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"files": [
{
"path": "package.json",
"result": "identical"
},
{
"path": "routes/data/lambda.js",
"result": {
"content": "import{getData as o}from\"#lib/data.js\";export const GET=()=>{console.log(\"got\",o())};"
}
}
]
}
Loading

0 comments on commit 2852249

Please sign in to comment.