Skip to content

Commit ff43ad2

Browse files
committed
fix: local imports in builds
1 parent df8289a commit ff43ad2

File tree

7 files changed

+71
-41
lines changed

7 files changed

+71
-41
lines changed

.changeset/red-dancers-march.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@pizzajsdev/react-router-hono': patch
3+
'@pizzajsdev/app-router-fs': patch
4+
'@pizzajsdev/utils': patch
5+
'@pizzajsdev/i18n': patch
6+
---
7+
8+
fix local imports in builds

examples/basic/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"dependencies": {
1313
"@hono/node-server": "^1.14.1",
1414
"@pizzajsdev/app-router-fs": "^0.3.0",
15-
"@pizzajsdev/react-router-hono": "^0.3.1",
15+
"@pizzajsdev/react-router-hono": "workspace:*",
1616
"@react-router/node": "^7.6.0",
1717
"@react-router/serve": "^7.6.0",
1818
"hono": "^4.7.9",

packages/app-router-fs/tsup.config.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,21 @@ const config: Options = {
1515
treeshake: true,
1616
skipNodeModulesBundle: true,
1717
external: ['node_modules'],
18+
plugins: [
19+
{
20+
// https://github.com/egoist/tsup/issues/953
21+
// ensuring that all local imports in `.js` files import from `.js` files.
22+
name: 'fix-esm-js-imports',
23+
renderChunk(code) {
24+
if (this.format === 'esm') {
25+
const regexEsm = /from(?<space>[\s]*)(?<quote>['"])(?<import>\.[^'"]+)['"]/g
26+
return {
27+
code: code.replace(regexEsm, 'from$<space>$<quote>$<import>.js$<quote>'),
28+
}
29+
}
30+
},
31+
},
32+
],
1833
}
1934

2035
export default defineConfig([config])

packages/i18n/tsup.config.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,21 @@ const config: Options = {
1515
treeshake: true,
1616
skipNodeModulesBundle: true,
1717
external: ['node_modules'],
18+
plugins: [
19+
{
20+
// https://github.com/egoist/tsup/issues/953
21+
// ensuring that all local imports in `.js` files import from `.js` files.
22+
name: 'fix-esm-js-imports',
23+
renderChunk(code) {
24+
if (this.format === 'esm') {
25+
const regexEsm = /from(?<space>[\s]*)(?<quote>['"])(?<import>\.[^'"]+)['"]/g
26+
return {
27+
code: code.replace(regexEsm, 'from$<space>$<quote>$<import>.js$<quote>'),
28+
}
29+
}
30+
},
31+
},
32+
],
1833
}
1934

2035
export default defineConfig([config])

packages/react-router-hono/tsup.config.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,21 @@ const config: Options = {
1515
treeshake: true,
1616
skipNodeModulesBundle: true,
1717
external: ['node_modules'],
18+
plugins: [
19+
{
20+
// https://github.com/egoist/tsup/issues/953
21+
// ensuring that all local imports in `.js` files import from `.js` files.
22+
name: 'fix-esm-js-imports',
23+
renderChunk(code) {
24+
if (this.format === 'esm') {
25+
const regexEsm = /from(?<space>[\s]*)(?<quote>['"])(?<import>\.[^'"]+)['"]/g
26+
return {
27+
code: code.replace(regexEsm, 'from$<space>$<quote>$<import>.js$<quote>'),
28+
}
29+
}
30+
},
31+
},
32+
],
1833
}
1934

2035
export default defineConfig([config])

packages/utils/tsup.config.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,21 @@ const config: Options = {
1515
treeshake: true,
1616
skipNodeModulesBundle: true,
1717
external: ['node_modules'],
18+
plugins: [
19+
{
20+
// https://github.com/egoist/tsup/issues/953
21+
// ensuring that all local imports in `.js` files import from `.js` files.
22+
name: 'fix-esm-js-imports',
23+
renderChunk(code) {
24+
if (this.format === 'esm') {
25+
const regexEsm = /from(?<space>[\s]*)(?<quote>['"])(?<import>\.[^'"]+)['"]/g
26+
return {
27+
code: code.replace(regexEsm, 'from$<space>$<quote>$<import>.js$<quote>'),
28+
}
29+
}
30+
},
31+
},
32+
],
1833
}
1934

2035
export default defineConfig([config])

pnpm-lock.yaml

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

0 commit comments

Comments
 (0)