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
  • Loading branch information
Adam McKee committed Nov 6, 2024
1 parent ca35659 commit a1e9be1
Show file tree
Hide file tree
Showing 83 changed files with 1,387 additions and 275 deletions.
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 }
9 changes: 9 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,9 @@
{
"dependencies": "unused",
"sources": [
{
"imports": [],
"path": "routes/data/lambda.js"
}
]
}
17 changes: 17 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,17 @@
{
"dependencies": "unused",
"sources": [
{
"imports": [],
"path": "lib/data.js"
},
{
"imports": [
{
"relativeSource": "lib/data.js"
}
],
"path": "routes/data/lambda.js"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"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,14 @@
[
{
"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,23 @@
{
"dependencies": "required",
"sources": [
{
"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,10 @@
[
{
"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,14 @@
[
{
"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,23 @@
{
"dependencies": "required",
"sources": [
{
"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,21 @@
{
"type": "module",
"imports": {
"#data": {
"default": "./lib/data-polyfill.js",
"module-sync": "./lib/data-polyfill.js",
"node": {
"module-sync": "data-dep",
"default": "./lib/data-polyfill.js"
}
},
"#log": {
"default": "log-dep",
"module-sync": "log-dep",
"node": {
"module-sync": "./lib/tla-log.js",
"default": "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,6 @@
[
{
"path": "routes/data/lambda.js",
"result": "identical"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[
{
"path": "routes/data/lambda.js",
"result": {
"content": "import{getData as o}from\"#lib/data.js\";export const GET=()=>{console.log(\"got\",o())};"
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"dependencies": "required",
"sources": [
{
"imports": [
{
"packageDependency": {
"package": "data-dep",
"subpath": null
}
}
],
"path": "routes/data/lambda.js"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"entrypoint": "routes/data/lambda.js"
}

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.

Loading

0 comments on commit a1e9be1

Please sign in to comment.