estrella icon indicating copy to clipboard operation
estrella copied to clipboard

Relative imports aren't rewritten relative to outfile

Open StarpTech opened this issue 3 years ago • 0 comments

I'd expect the imports are rewritten or copied in no-bundle mode otherwise the result can't be executed.

// index.js
const { build, cliopts } = require("estrella")
const p = build({
  	entry: "foo/src/entry.ts",
  	outfile: "foo/dist/server.js",
	watch: true,
	cwd: ".",
	incremental: true,
	clear: true,
	logLevel: "debug",
	target: "node16",
	format: "cjs",
	tsc: false,
  	run: ["node", "foo/dist/server.js"],
})
// entry.ts
import "./config";
console.log("hello")

Directory structure

.
├── foo/
│   ├── dist/
│   │   └── server.js
│   └── src/
│       ├── config.ts
│       └── entry.ts
└── index.js

Error:

Error: Cannot find module './config.js'
...
 code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/starptech/repositories/foo/dist/server.js'
  ]

StarpTech avatar May 18 '22 22:05 StarpTech