-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: npm init #9
Comments
Nice! Thanks for making this. I'm happy to let you maintain it. Some feedbackGenerating two build files seems unnecessary (i.e. I see you've added dependencies listed in package.json to esbuild's "external" list. This is going to be a problem for most people! i.e.
A key part of the esbuild project is to be a really good bundler and this may prevent a lot of people from bundling libraries, which is pretty common when you "bundle" javascript. I propose that you remove this and instead add a sentence of documentation to the postscript of the "init" action (shown when Mentioned above already but worth clarifying: You're making a lot of assumptions about what people want to make. For example Again I recommend that you generate a super simple and minimal build.js, like this: #!/usr/bin/env node
const { build } = require("estrella")
const pkg = require("./package.json")
build({
entry: "src/index.ts",
outfile: pkg.main,
}) :-) |
Thank you very much for the feedback. You are right, the lightness of the setup is the biggest plus. I will adjust that in Obviously I took the settings from an existing project ;) I separated the config there, because I reused it for a Jest transformer. My const esbuild = require('esbuild')
const common = require('./build.config.js')
module.exports = {
// https://jestjs.io/docs/en/troubleshooting#caching-issues
getCacheKey() {
return Math.random().toString()
},
process(content, filename) {
let result = esbuild.buildSync({
...common,
sourcemap: 'inline',
write: false,
entryPoints: [filename],
})
return new TextDecoder('utf-8').decode(result.outputFiles[0].contents)
},
} And the "jest": {
"transform": {
"^.+\\.jsx?$": "./build.jest.js"
},
"testEnvironment": "node",
"testPathIgnorePatterns": [
"node_modules/",
"dist/"
]
}, Do you have an idea how to nicely combine this with Estrella? I might add the special cases as further options for the init script:
I'll post an update here once I implemented it. Thanks again for the great work on Estrella and for clarifying the philosophy behind it. |
Regarding the "jest" file: I'm not familiar with Jest enough to know what to do here. build.js const { build, file } = require('estrella')
if (module.id != ".") {
// imported by jest as a transformer
return module.exports = {
getCacheKey() { /* ... */ },
async process(content, filename) {
await build({
entry: filename,
outfile: tempfile
})
return file.read(tempfile, "utf8")
}
}
}
// running directly -- build product
build({
entry: "main.ts",
outfile: "out/app.js"
}) Alternatively just keep the jest transformer separate, maybe in a "misc" directory. |
I fixed create-estrella to use the simple sample you suggested. More templates will follow and are tracked here https://github.com/holtwick/create-estrella/issues The In order to get it work, a synchronous build would be required. It would also be nice to be able to build to a string directly and the handle the result oneself. But I understand if this is out of scope of estrella, even though it would be nice to have ;) |
Here you go, more templates for |
I created a little something to get started with a new estrella project: https://github.com/holtwick/create-estrella
You can now enter:
To get started.
If you like the idea, I can also pass the project to you.
Other interesting templates might be:
It might also be nice to have it right inside estrella command line tool itself, like:
The text was updated successfully, but these errors were encountered: