Skip to content

Commit

Permalink
Typos
Browse files Browse the repository at this point in the history
  • Loading branch information
Septh committed May 4, 2024
1 parent 082f24f commit 1526ed7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ How to handle the `node:` scheme used in recent versions of Node (i.e., `import
> _Note that scheme handling is always applied, regardless of the `builtins` options being enabled or not._
#### packagePath?: string | string[] = []
If you're working with monorepos, the `packagePath` option is made for you. It can take a path, or an array of paths, to your package.json file(s). If not specified, the default is to start with the current directory's package.json then go up scan for all `package.json` files in parent directories recursively until either the root git directory is reached or until no other `package.json` can be found.
If you're working with monorepos, the `packagePath` option is made for you. It can take a path, or an array of paths, to your package.json file(s). If not specified, the default is to start with the current directory's package.json then go up scan for all `package.json` files in parent directories recursively until either the root git directory is reached, the root of the monorepo is reached, or no other `package.json` can be found.

#### deps?: boolean = true<br>devDeps?: boolean = false<br>peerDeps?: boolean = true<br>optDeps?: boolean = true
Set the `deps`, `devDeps`, `peerDeps` and `optDeps` options to `false` to prevent the corresponding dependencies from being externalized, therefore letting Rollup bundle them with your code.
Expand Down Expand Up @@ -151,7 +151,7 @@ nodeExternals({
It uses an exact match against your imports _as written in your code_. No resolving of path aliases or substitutions is made:

```js
// In your code, say '@/lib' is an alias for node_modules/deep/path/to/some/lib:
// In your code, say '@/lib' is an alias for source/deep/path/to/some/lib:
import something from '@/lib'
```

Expand All @@ -160,7 +160,7 @@ If you don't want `lib` bundled in, then write:
```js
// In rollup.config.js:
nodeExternals({
include: '@/mylib'
include: '@/lib'
})
```

Expand All @@ -180,13 +180,13 @@ export default {
}
```

As a general rule of thumb, you will want to always make this plugin the first one in the `plugins` array.
Note that as of version 7, this plugin's `resolveId` hook has a `order: 'pre'` property that will make Rollup call it very early in the module resolution process. Nevertheless, it is best to always make this plugin the first one in the `plugins` array.

### 4/ Rollup rules
Rollup's own `external` configuration option always takes precedence over this plugin. This is intentional.

### 5/ Using with Vite
While this plugin has always been compatible with Vite, it was previously necessary to use the following `vite.config.js` to make it work reliably in every situations:
While this plugin has always been compatible with Vite, it was previously necessary to use the following `vite.config.js` to make it work reliably in every situation:

```js
import { defineConfig } from 'vite'
Expand Down
12 changes: 6 additions & 6 deletions source/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ interface PackageJson {
// Get our own name and version
const { name, version } = createRequire(import.meta.url)('../package.json') as PackageJson

// Files that mark the root of a workspace
// Files that mark the root of a monorepo
const workspaceRootFiles = new Set([
'pnpm-workspace.yaml', // pnpm
'lerna.json', // Lerna
Expand Down Expand Up @@ -125,8 +125,8 @@ function nodeExternals(options: ExternalsOptions = {}): Plugin {

const config: Config = { ...defaults, ...options }

let include: RegExp[] = [], // Initialized to empty arrays
exclude: RegExp[] = [] // as a workaround to https://github.com/Septh/rollup-plugin-node-externals/issues/30
let include: RegExp[] = [], // Initialized to empty arrays as a workaround
exclude: RegExp[] = [] // to https://github.com/Septh/rollup-plugin-node-externals/issues/30

const isIncluded = (id: string) => include.length > 0 && include.some(rx => rx.test(id)),
isExcluded = (id: string) => exclude.length > 0 && exclude.some(rx => rx.test(id))
Expand Down Expand Up @@ -157,9 +157,9 @@ function nodeExternals(options: ExternalsOptions = {}): Plugin {
// from cwd up to the root of the git repo, the root of the monorepo,
// or the root of the volume, whichever comes first.
const packagePaths = ([] as string[])
.concat(config.packagePath)
.filter(isString)
.map(packagePath => path.resolve(packagePath))
.concat(config.packagePath)
.filter(isString)
.map(packagePath => path.resolve(packagePath))
if (packagePaths.length === 0) {
for (
let current = process.cwd(), previous: string | undefined = undefined;
Expand Down

0 comments on commit 1526ed7

Please sign in to comment.