Skip to content

Commit

Permalink
precompile edge-runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
Schniz committed May 26, 2022
1 parent 82434f6 commit f96ce8a
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 3 deletions.
7 changes: 6 additions & 1 deletion lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const escape = require('shell-quote').quote
const { quote } = require('shell-quote')
const { ESLint } = require('eslint')

const eslint = new ESLint()
Expand Down Expand Up @@ -26,3 +26,8 @@ module.exports = {
]
},
}

function escape(str) {
const escaped = quote(str)
return escaped.replace(/\\@/g, '@')
}
70 changes: 70 additions & 0 deletions packages/next/compiled/@edge-runtime/primitives/index.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name":"@edge-runtime/primitives","main":"index.js","license":"MPLv2"}
1 change: 1 addition & 0 deletions packages/next/compiled/edge-runtime/index.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/next/compiled/edge-runtime/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name":"edge-runtime","main":"index.js","license":"MPLv2"}
2 changes: 1 addition & 1 deletion packages/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
},
"dependencies": {
"@next/env": "12.1.7-canary.16",
"edge-runtime": "1.0.1-beta.9",
"@edge-runtime/primitives": "1.0.1-beta.9",
"caniuse-lite": "^1.0.30001332",
"postcss": "8.4.5",
Expand Down Expand Up @@ -190,6 +189,7 @@
"debug": "4.1.1",
"devalue": "2.0.1",
"domain-browser": "4.19.0",
"edge-runtime": "1.0.1-beta.9",
"etag": "1.8.1",
"events": "3.3.0",
"find-cache-dir": "3.3.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/next/server/web/sandbox/context.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Primitives } from '@edge-runtime/vm'
import type { WasmBinding } from '../../../build/webpack/loaders/get-module-build-info'
import { EDGE_UNSUPPORTED_NODE_APIS } from '../../../shared/lib/constants'
import { EdgeRuntime } from 'edge-runtime'
import { EdgeRuntime } from 'next/dist/compiled/edge-runtime'
import { readFileSync, promises as fs } from 'fs'
import { validateURL } from '../utils'

Expand Down
24 changes: 24 additions & 0 deletions packages/next/taskfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,28 @@ export async function ncc_acorn(task, opts) {
.target('compiled/acorn')
}

// eslint-disable-next-line camelcase
externals['@edge-runtime/primitives'] =
'next/dist/compiled/@edge-runtime/primitives'
export async function ncc_edge_runtime_primitives(task, opts) {
await task
.source(
opts.src ||
relative(__dirname, require.resolve('@edge-runtime/primitives'))
)
.ncc({ packageName: '@edge-runtime/primitives', externals })
.target('compiled/@edge-runtime/primitives')
}

// eslint-disable-next-line camelcase
externals['edge-runtime'] = 'next/dist/compiled/edge-runtime'
export async function ncc_edge_runtime(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('edge-runtime')))
.ncc({ packageName: 'edge-runtime', externals })
.target('compiled/edge-runtime')
}

// eslint-disable-next-line camelcase
export async function ncc_next__react_dev_overlay(task, opts) {
const overlayExternals = {
Expand Down Expand Up @@ -1624,6 +1646,8 @@ export async function ncc(task, opts) {
'ncc_p_limit',
'ncc_raw_body',
'ncc_cssnano_simple',
'ncc_edge_runtime_primitives',
'ncc_edge_runtime',
'ncc_image_size',
'ncc_get_orientation',
'ncc_hapi_accept',
Expand Down
10 changes: 10 additions & 0 deletions packages/next/types/misc.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,16 @@ declare module 'next/dist/compiled/process' {
export = m
}

declare module 'next/dist/compiled/edge-runtime' {
import m from 'edge-runtime'
export = m
}

declare module 'next/dist/compiled/@edge-runtime/primitives' {
import m from '@edge-runtime/primitives'
export = m
}

declare module 'pnp-webpack-plugin' {
import webpack from 'webpack4'

Expand Down

0 comments on commit f96ce8a

Please sign in to comment.