Skip to content
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
9 changes: 9 additions & 0 deletions .changeset/bob-the-bundler-167-dependencies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"bob-the-bundler": patch
---
dependencies updates:
- Updated dependency [`[email protected]` ↗︎](https://www.npmjs.com/package/execa/v/6.1.0) (from `5.1.1`, in `dependencies`)
- Updated dependency [`globby@^13.1.3` ↗︎](https://www.npmjs.com/package/globby/v/13.1.3) (from `^11.0.0`, in `dependencies`)
- Updated dependency [`p-limit@^4.0.0` ↗︎](https://www.npmjs.com/package/p-limit/v/4.0.0) (from `^3.1.0`, in `dependencies`)
- Updated dependency [`yargs@^17.6.2` ↗︎](https://www.npmjs.com/package/yargs/v/17.6.2) (from `^17.5.1`, in `dependencies`)
- Updated dependency [`zod@^3.20.2` ↗︎](https://www.npmjs.com/package/zod/v/3.20.2) (from `^3.17.3`, in `dependencies`)
5 changes: 5 additions & 0 deletions .changeset/nervous-carpets-shop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'bob-the-bundler': major
---

bundle bob in esm instead cjs
17 changes: 17 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2020,
},
overrides: [
{
files: 'src/**/*.ts',
excludedFiles: ['*.spec.ts'],
plugins: ['import'],
rules: {
'import/extensions': ['error', 'ignorePackages'],
},
},
],
};
2 changes: 2 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ jobs:
run: yarn test:ts
- name: Lint Prettier
run: yarn lint:prettier
- name: Lint ESLint
run: yarn lint
Comment on lines +42 to +43
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<3

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't worry I plan to switch to pnpm :)))

19 changes: 12 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "bob-the-bundler",
"version": "4.1.1",
"type": "module",
"description": "Bob The Bundler!",
"repository": {
"url": "[email protected]:kamilkisiela/bob.git",
Expand All @@ -23,6 +24,7 @@
],
"scripts": {
"build": "rimraf dist && tsc",
"lint": "eslint --cache --cache-location node_modules/.cache/.eslintcache --ignore-path .gitignore .",
"lint:prettier": "prettier --cache --check .",
"prepublish": "yarn build",
"prerelease": "yarn build",
Expand All @@ -38,30 +40,33 @@
"@vercel/ncc": "^0.36.0",
"consola": "^2.15.3",
"dependency-graph": "^0.11.0",
"execa": "5.1.1",
"execa": "6.1.0",
"fs-extra": "^11.1.0",
"globby": "^11.0.0",
"globby": "^13.1.3",
"js-yaml": "^4.1.0",
"lodash.get": "^4.4.2",
"mkdirp": "^1.0.4",
"p-limit": "^3.1.0",
"p-limit": "^4.0.0",
"resolve.exports": "^1.1.0",
"tslib": "^2.0.0",
"tsup": "^6.5.0",
"yargs": "^17.5.1",
"zod": "^3.17.3"
"yargs": "^17.6.2",
"zod": "^3.20.2"
},
"devDependencies": {
"@actions/core": "1.10.0",
"@changesets/changelog-github": "0.4.8",
"@changesets/cli": "2.24.4",
"@changesets/cli": "2.26.0",
"@theguild/prettier-config": "1.0.0",
"@types/fs-extra": "9.0.13",
"@types/js-yaml": "4.0.5",
"@types/lodash.get": "4.4.7",
"@types/mkdirp": "1.0.2",
"@types/node": "16.18.10",
"@types/node": "18.11.17",
"@types/yargs": "17.0.17",
"@typescript-eslint/parser": "5.47.0",
"eslint": "8.30.0",
"eslint-plugin-import": "2.26.0",
"jest-snapshot-serializer-raw": "1.2.0",
"prettier": "2.8.1",
"rimraf": "3.0.2",
Expand Down
2 changes: 1 addition & 1 deletion src/action.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as core from '@actions/core';
import { resolve } from 'path';
import { getAffectedPackages } from './commands/run';
import { getAffectedPackages } from './commands/run.js';

async function run(): Promise<void> {
try {
Expand Down
18 changes: 9 additions & 9 deletions src/commands/bootstrap.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import globby from 'globby';
import { globby } from 'globby';
import pLimit from 'p-limit';
import * as path from 'path';
import * as fse from 'fs-extra';
import { createCommand } from '../command';
import { buildArtifactDirectories } from '../constants';
import { getRootPackageJSON } from '../utils/get-root-package-json';
import { getWorkspaces } from '../utils/get-workspaces';
import { getWorkspacePackagePaths } from '../utils/get-workspace-package-paths';
import { rewriteCodeImports } from '../utils/rewrite-code-imports';
import path from 'path';
import fse from 'fs-extra';
import { createCommand } from '../command.js';
import { buildArtifactDirectories } from '../constants.js';
import { getRootPackageJSON } from '../utils/get-root-package-json.js';
import { getWorkspaces } from '../utils/get-workspaces.js';
import { getWorkspacePackagePaths } from '../utils/get-workspace-package-paths.js';
import { rewriteCodeImports } from '../utils/rewrite-code-imports.js';

/** The default bob fields that should be within a package.json */
export const presetFields = Object.freeze({
Expand Down
24 changes: 12 additions & 12 deletions src/commands/build.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import * as assert from 'assert';
import execa from 'execa';
import * as fse from 'fs-extra';
import globby from 'globby';
import assert from 'assert';
import { execa, ExecaReturnValue } from 'execa';
import fse from 'fs-extra';
import { globby } from 'globby';
import pLimit from 'p-limit';
import { resolve, join, dirname } from 'path';
import { Consola } from 'consola';
import get from 'lodash.get';
import mkdirp from 'mkdirp';

import { getRootPackageJSON } from '../utils/get-root-package-json';
import { getWorkspaces } from '../utils/get-workspaces';
import { createCommand } from '../command';
import { getBobConfig } from '../config';
import { rewriteExports } from '../utils/rewrite-exports';
import { presetFields, presetFieldsESM } from './bootstrap';
import { getWorkspacePackagePaths } from '../utils/get-workspace-package-paths';
import { getRootPackageJSON } from '../utils/get-root-package-json.js';
import { getWorkspaces } from '../utils/get-workspaces.js';
import { createCommand } from '../command.js';
import { getBobConfig } from '../config.js';
import { rewriteExports } from '../utils/rewrite-exports.js';
import { presetFields, presetFieldsESM } from './bootstrap.js';
import { getWorkspacePackagePaths } from '../utils/get-workspace-package-paths.js';

export const DIST_DIR = 'dist';

Expand Down Expand Up @@ -58,7 +58,7 @@ function compilerOptionsToArgs(options: Record<string, unknown>): string[] {
return Object.entries(options).flatMap(([key, value]) => [`--${key}`, `${value}`]);
}

function assertTypeScriptBuildResult(result: execa.ExecaReturnValue) {
function assertTypeScriptBuildResult(result: ExecaReturnValue) {
if (result.exitCode !== 0) {
console.log('TypeScript compiler exited with non-zero exit code.');
console.log(result.stdout);
Expand Down
27 changes: 12 additions & 15 deletions src/commands/check.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import globby from 'globby';
import { globby } from 'globby';
import zod from 'zod';
import * as fse from 'fs-extra';
import resolve from 'resolve.exports';
import { createCommand } from '../command';
import { presetFields } from './bootstrap';
import fse from 'fs-extra';
import * as resolve from 'resolve.exports';
import { createCommand } from '../command.js';
import { presetFields } from './bootstrap.js';
import path from 'path';
import pLimit from 'p-limit';
import execa from 'execa';
import { getRootPackageJSON } from '../utils/get-root-package-json';
import { getWorkspaces } from '../utils/get-workspaces';
import { getWorkspacePackagePaths } from '../utils/get-workspace-package-paths';
import { getBobConfig } from '../config';
import { execa, ExecaChildProcess } from 'execa';
import { getRootPackageJSON } from '../utils/get-root-package-json.js';
import { getWorkspaces } from '../utils/get-workspaces.js';
import { getWorkspacePackagePaths } from '../utils/get-workspace-package-paths.js';
import { getBobConfig } from '../config.js';

const ExportsMapEntry = zod.object({
default: zod.string(),
Expand Down Expand Up @@ -313,7 +313,7 @@ async function checkExportsMapIntegrity(args: {
});

const contents = await fse.readFile(absoluteFilePath, 'utf-8');
if (contents.startsWith('#!/usr/bin/env node\n') === false) {
if (!contents.startsWith('#!/usr/bin/env node\n')) {
throw new Error(
"Binary file '" +
absoluteFilePath +
Expand All @@ -326,10 +326,7 @@ async function checkExportsMapIntegrity(args: {

const timeout = `;setTimeout(() => { throw new Error("The Node.js process hangs. There is probably some side-effects. All exports should be free of side effects.") }, 500).unref()`;

function runRequireJSFileCommand(args: {
cwd: string;
path: string;
}): execa.ExecaChildProcess<string> {
function runRequireJSFileCommand(args: { cwd: string; path: string }): ExecaChildProcess {
return execa('node', ['-e', `require('${args.path}')${timeout}`], {
cwd: args.cwd,
reject: false,
Expand Down
6 changes: 3 additions & 3 deletions src/commands/runify.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import globby from 'globby';
import * as fse from 'fs-extra';
import { globby } from 'globby';
import fse from 'fs-extra';
import pLimit from 'p-limit';
import fs from 'fs-extra';
import { DepGraph } from 'dependency-graph';
Expand All @@ -9,7 +9,7 @@ import ncc from '@vercel/ncc';
import { build as tsup } from 'tsup';
import { spawn } from 'child_process';

import { createCommand } from '../command';
import { createCommand } from '../command.js';

export const distDir = 'dist';

Expand Down
13 changes: 7 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#!/usr/bin/env node
import yargs, { Argv } from 'yargs';
import { hideBin } from 'yargs/helpers';
import consola from 'consola';
import { CommandFactory } from './command';
import { buildCommand } from './commands/build';
import { runifyCommand } from './commands/runify';
import { bootstrapCommand } from './commands/bootstrap';
import { checkCommand } from './commands/check';
import { CommandFactory } from './command.js';
import { buildCommand } from './commands/build.js';
import { runifyCommand } from './commands/runify.js';
import { bootstrapCommand } from './commands/bootstrap.js';
import { checkCommand } from './commands/check.js';

async function main() {
const root: Argv = yargs.scriptName('bob').detectLocale(false).version();
const root: Argv = yargs(hideBin(process.argv)).scriptName('bob').detectLocale(false).version();
Comment on lines -11 to +12
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


const commands: CommandFactory<any, any>[] = [
buildCommand,
Expand Down
4 changes: 2 additions & 2 deletions src/utils/get-root-package-json.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import globby from 'globby';
import * as fse from 'fs-extra';
import { globby } from 'globby';
import fse from 'fs-extra';

export async function getRootPackageJSON(cwd = process.cwd()) {
const [rootPackageJSONPath] = await globby('package.json', {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/get-workspace-package-paths.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import globby from 'globby';
import { globby } from 'globby';
import path from 'path';

import { buildArtifactDirectories } from '../constants';
import { buildArtifactDirectories } from '../constants.js';

export async function getWorkspacePackagePaths(workspaces: string[], cwd = process.cwd()) {
const packageJSONPaths = await globby(
Expand Down
2 changes: 1 addition & 1 deletion src/utils/rewrite-code-imports.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { rewriteCodeImports } from './rewrite-code-imports';
import * as path from 'path';
import path from 'path';
import { it, expect } from 'vitest';

const fixturePath = path.join(__dirname, '__fixtures__', 'index.ts');
Expand Down
4 changes: 2 additions & 2 deletions src/utils/rewrite-code-imports.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as fse from 'fs-extra';
import * as path from 'path';
import fse from 'fs-extra';
import path from 'path';

function isFolderSync(path: string) {
try {
Expand Down
2 changes: 1 addition & 1 deletion test/integration.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from 'path';
import execa from 'execa';
import { execa } from 'execa';
import * as fse from 'fs-extra';
import { it, expect } from 'vitest';

Expand Down
2 changes: 1 addition & 1 deletion test/ts-tests/run-tests.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import execa from 'execa';
import { execa } from 'execa';
import path from 'node:path';
import { fileURLToPath } from 'node:url';

Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"module": "commonjs",
"module": "es2020",
"strictNullChecks": true,
"target": "es2018",
"lib": ["esnext"],
Expand Down
Loading