Skip to content

Commit 5abc39d

Browse files
jobalaeduardoboucas
andauthoredJan 16, 2023
feat: install framework runtime (#4812)
* chore: install runtime * chore: change featureflag indexing * chore: address PR concerns * Update packages/build/src/core/build.ts Co-authored-by: Eduardo Bouças <mail@eduardoboucas.com> * chore: use .some to avoid looping twice Co-authored-by: Eduardo Bouças <mail@eduardoboucas.com>
1 parent ffffcdb commit 5abc39d

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed
 

‎packages/build/src/core/build.ts

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { supportedRuntimes } from '@netlify/framework-info'
2+
13
import { getErrorInfo } from '../error/info.js'
24
import { startErrorMonitor } from '../error/monitor/start.js'
35
import { getBufferLogs, getSystemLogger } from '../log/logger.js'
@@ -77,6 +79,7 @@ const tExecBuild = async function ({
7779
timeline,
7880
devCommand,
7981
quiet,
82+
framework,
8083
}) {
8184
const configOpts = getConfigOpts({
8285
config,
@@ -124,6 +127,20 @@ const tExecBuild = async function ({
124127
timers,
125128
quiet,
126129
})
130+
131+
if (featureFlags.build_automatic_runtime && framework) {
132+
const runtime = supportedRuntimes[framework]
133+
134+
if (runtime !== undefined) {
135+
const skip = childEnv[runtime.skipFlag] === 'true'
136+
const installed = netlifyConfig.plugins.some((plugin) => plugin.package === runtime.package)
137+
138+
if (!installed && !skip) {
139+
netlifyConfig.plugins.push({ package: runtime.package })
140+
}
141+
}
142+
}
143+
127144
const constants = await getConstants({
128145
configPath,
129146
buildDir,

‎packages/build/src/core/main.ts

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export default async function buildSite(flags: Partial<BuildCLIFlags> = {}): Pro
6565
debug,
6666
testOpts,
6767
errorParams,
68+
framework,
6869
})
6970
await handleBuildSuccess({
7071
framework,

‎packages/framework-info/src/main.js

+5
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,8 @@ export const getFramework = async function (frameworkId, options) {
126126
const context = await getContext(options)
127127
return get(frameworkId, context)
128128
}
129+
130+
export const supportedRuntimes = {
131+
next: { package: '@netlify/plugin-nextjs', skipFlag: 'NETLIFY_NEXT_PLUGIN_SKIP' },
132+
gatsby: { package: '@netlify/plugin-gatsby', skipFlag: 'NETLIFY_GATSBY_PLUGIN_SKIP' },
133+
}

0 commit comments

Comments
 (0)
Please sign in to comment.