Skip to content

Commit

Permalink
Merge pull request #165 from fritx/docs-contributing
Browse files Browse the repository at this point in the history
Fix esbuild module resolve and missing parameter passing
  • Loading branch information
tipiirai authored Jan 15, 2024
2 parents 515d59b + 12df668 commit 73b931a
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 6 deletions.
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

0 comments on commit 73b931a

Please sign in to comment.