Skip to content

[pull] canary from vercel:canary #116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 12, 2025
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { ReactNode } from 'react'
export default function Root({ children }: { children: ReactNode }) {
return (
<html>
<body>{children}</body>
</html>
)
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Svg from './next.svg'
export default function Page() {
return (
<>
<p>hello world</p>
<div id="the-svg">
<Svg />
</div>
</>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = (_source) => {
process.env.TEST_THIS_THING = 'def'
return 'export default () => "The svg rendered"'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const { join } = require('path')

/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
turbopack: {
rules: {
'*.svg': {
as: '*.js',
loaders: [join(__dirname, './custom-loader.js')],
},
},
},
webpack(config) {
config.module.rules.push({
test: /\.svg$/,
use: [join(__dirname, './custom-loader.js')],
})

return config
},
}

module.exports = nextConfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { nextTestSetup } from 'e2e-utils'

describe('webpack-loader-set-environment-variable', () => {
const { next } = nextTestSetup({
files: __dirname,
env: {
TEST_THIS_THING: 'def',
},
})

// Recommended for tests that check HTML. Cheerio is a HTML parser that has a jQuery like API.
it('loader that sets an environment variable should work', async () => {
const $ = await next.render$('/')
expect($('p').text()).toBe('hello world')
expect($('#the-svg').text()).toBe('The svg rendered')
})
})
1,200 changes: 799 additions & 401 deletions test/rspack-dev-tests-manifest.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ process.env = new Proxy(originalEnv, {
}
return Reflect.get(target, prop)
},
set(target, prop, value) {
return Reflect.set(target, prop, value)
},
})

export function getReadEnvVariables(): string[] {
Expand Down
Loading