Skip to content
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

Fix esbuild module resolve and missing parameter passing #165

Merged
merged 1 commit into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 35 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,38 @@ Please try to use the original style in the codebase. Do not introduce new rules
Nue is not using Prettier or ESLint because they will increase the project size to 40MB. The `.prettierrc.yaml` file on the root directory does the job well enough.





### Testing

```sh
# if using bun
bun install
bun install --no-save esbuild
bun test

# if using node
npm install
npm install --no-save jest jest-extended esbuild
node --experimental-vm-modules node_modules/jest/bin/jest --runInBand
```


### Linking

```sh
# if using bun
bun install
cd packages/nuekit
bun link
cd my/nue/project
nue
nue build --production

# if using node
npm install
cd packages/nuekit
npm link
cd my/nue/project
npm install --save-dev esbuild
node $(which nue)
node $(which nue) build --production
```
1 change: 1 addition & 0 deletions packages/nuekit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
},
"dependencies": {
"diff-dom": "^5.0.6",
"import-meta-resolve": "^4.0.0",
"js-yaml": "^4.1.0",
"nuejs-core": "^0.3.0",
"nuemark": "^0.1.0"
Expand Down
3 changes: 2 additions & 1 deletion packages/nuekit/src/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
/* Builders for CSS, JS, and TS */

import { join, extname } from 'node:path'
import { resolve } from 'import-meta-resolve'

export async function getBuilder(is_esbuild) {
try {
return is_esbuild ? await import('esbuild') : Bun
return is_esbuild ? await import(await resolve('esbuild', `file://${process.cwd()}/`)) : Bun
} catch {
throw 'Bundler not found. Please use Bun or install esbuild'
}
Expand Down
1 change: 1 addition & 0 deletions packages/nuekit/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export function getArgs(argv) {
else if (['-h', '--help'].includes(arg)) args.help = true
else if (['-v', '--verbose'].includes(arg)) args.verbose = true
else if (['-s', '--stats'].includes(arg)) args.stats = true
else if (['-b', '--esbuild'].includes(arg)) args.esbuild = true

// string values
else if (['-e', '--environment'].includes(arg)) opt = 'env'
Expand Down
5 changes: 3 additions & 2 deletions packages/nuekit/src/nuekit.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const DOCTYPE = '<!doctype html>\n\n'
const NOT_FOUND = -2

export async function createKit(args) {
const { root, is_prod, env } = args
const { root, is_prod, esbuild } = args

// site: various file based functions
const site = await createSite(args)
Expand All @@ -28,7 +28,7 @@ export async function createKit(args) {
const is_dev = !is_prod

// make sure @nue dir has all the latest
if (!args.dryrun) await init({ dist, is_dev })
if (!args.dryrun) await init({ dist, is_dev, esbuild })



Expand Down Expand Up @@ -186,6 +186,7 @@ export async function createKit(args) {
await buildJS({
outdir: join(process.cwd(), dist, file.dir),
path: join(process.cwd(), root, path),
esbuild,
minify: is_prod,
bundle
})
Expand Down