Skip to content

Commit

Permalink
Merge branch 'improve-cli-args' of github.com:Willem-Jaap/next.js int…
Browse files Browse the repository at this point in the history
…o improve-cli-args
  • Loading branch information
Willem-Jaap committed May 7, 2023
2 parents a486c38 + e44c847 commit 5052936
Show file tree
Hide file tree
Showing 276 changed files with 178,167 additions and 2,967 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build_test_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,9 @@ jobs:
- build
- build-wasm
- build-native
permissions:
contents: write
id-token: write
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN_ELEVATED }}
steps:
Expand Down Expand Up @@ -997,6 +1000,7 @@ jobs:
name: wasm-binaries
path: packages/next-swc/crates/wasm

- run: npm i -g npm@9 # need latest version for provenance
- run: npm i -g pnpm@${PNPM_VERSION}
- run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
- run: ./scripts/publish-native.js
Expand Down
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
provenance = true
save-exact = true
tag-version-prefix=""
strict-peer-dependencies = false
Expand Down
80 changes: 48 additions & 32 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ swc_relay = { version = "0.2.5" }
testing = { version = "0.33.4" }

# Turbo crates
turbo-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230420.2" }
turbo-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230425.4" }
# [TODO]: need to refactor embed_directory! macro usages, as well as resolving turbo_tasks::function, macros..
turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230420.2" }
turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230425.4" }
# [TODO]: need to refactor embed_directory! macro usage in next-core
turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230420.2" }
turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230425.4" }

# General Deps

Expand Down
14 changes: 7 additions & 7 deletions docs/advanced-features/instrumentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,30 @@ export function register() {
}
```

However, we recommend importing files with side effects using `require` from within your `register` function instead. The following example demonstrates a basic usage of `require` in a `register` function:
However, we recommend importing files with side effects using `import` from within your `register` function instead. The following example demonstrates a basic usage of `import` in a `register` function:

```ts
// /instrumentation.ts

export function register() {
require('package-with-side-effect')
export async function register() {
await import('package-with-side-effect')
}
```

By doing this, you can colocate all of your side effects in one place in your code, and avoid any unintended consequences from importing files.

We call `register` in all environments, so it's necessary to conditionally require any code that doesn't support both `edge` and `nodejs`. You can use the environment variable `NEXT_RUNTIME` to get the current environment. Importing an environment-specific code would look like this:
We call `register` in all environments, so it's necessary to conditionally import any code that doesn't support both `edge` and `nodejs`. You can use the environment variable `NEXT_RUNTIME` to get the current environment. Importing an environment-specific code would look like this:

```ts
// /instrumentation.ts

export function register() {
export async function register() {
if (process.env.NEXT_RUNTIME === 'nodejs') {
require('./instrumentation-node')
await import('./instrumentation-node')
}

if (process.env.NEXT_RUNTIME === 'edge') {
require('./instrumentation-edge')
await import('./instrumentation-edge')
}
}
```

0 comments on commit 5052936

Please sign in to comment.