Skip to content
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
2 changes: 2 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ on:
jobs:
deploy-preview:
runs-on: ubuntu-latest
env:
GITHUB_PULL_REQUEST_PREVIEW: 'true'
steps:
- uses: actions/checkout@v4
- name: Install Node 22
Expand Down
6 changes: 6 additions & 0 deletions packages/__docs__/webpack.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ import { globbySync } from 'globby'
import { merge } from 'webpack-merge'
import { processSingleFile } from './lib/build-docs.mjs'
import resolve from './resolve.mjs'
import webpack from 'webpack'
import TerserPlugin from 'terser-webpack-plugin'

const ENV = process.env.NODE_ENV || 'production'
const DEBUG = process.env.DEBUG || ENV === 'development'
const GITHUB_PULL_REQUEST_PREVIEW = process.env.GITHUB_PULL_REQUEST_PREVIEW || 'false'

const outputPath = resolvePath(import.meta.dirname, '__build__')
const resolveAliases = DEBUG ? { resolve } : {}
Expand Down Expand Up @@ -79,6 +82,9 @@ const config = merge(baseConfig, {
template: './src/index.html',
chunks: ['main'],
}),
new webpack.DefinePlugin({
'process.env.GITHUB_PULL_REQUEST_PREVIEW': JSON.stringify(GITHUB_PULL_REQUEST_PREVIEW),
}),
],
optimization: {
usedExports: true,
Expand Down
8 changes: 7 additions & 1 deletion packages/console/src/console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,13 @@ function logMessage(
message: string,
...args: unknown[]
) {
if (process.env.NODE_ENV !== 'production' && !condition) {
const isGitHubPullRequestPreview =
typeof process !== 'undefined' &&
process?.env?.GITHUB_PULL_REQUEST_PREVIEW === 'true'
if (
(isGitHubPullRequestPreview || process.env.NODE_ENV !== 'production') &&
!condition
) {
if (typeof console[level] === 'function') {
const renderStack = withRenderStack ? getRenderStack() : ''
//@ts-expect-error level can be 'constructor' which is not callable
Expand Down
6 changes: 5 additions & 1 deletion packages/emotion/src/InstUISettingsProvider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ function InstUISettingsProvider({
}: InstUIProviderProps) {
const finalDir = dir || useContext(TextDirectionContext)

if (process.env.NODE_ENV !== 'production' && finalDir === 'auto') {
if (
(process.env.NODE_ENV !== 'production' ||
process.env.GITHUB_PULL_REQUEST_PREVIEW === 'true') &&
finalDir === 'auto'
) {
console.warn(
"'auto' is not an supported value for the 'dir' prop. Please pass 'ltr' or 'rtl'"
)
Expand Down
10 changes: 8 additions & 2 deletions packages/emotion/src/getTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ const getTheme =
// we need to clone the ancestor theme not to override it
let currentTheme
if (Object.keys(ancestorTheme).length === 0) {
if (process.env.NODE_ENV !== 'production') {
if (
process.env.NODE_ENV !== 'production' ||
process.env.GITHUB_PULL_REQUEST_PREVIEW === 'true'
) {
console.warn(
'No theme provided for [InstUISettingsProvider], using default `canvas` theme.'
)
Expand All @@ -78,7 +81,10 @@ const getTheme =
// If the prop passed is not an Object, it will throw an error.
// We are using this fail-safe here for the non-TS users,
// because the whole page can break without a theme.
if (process.env.NODE_ENV !== 'production') {
if (
process.env.NODE_ENV !== 'production' ||
process.env.GITHUB_PULL_REQUEST_PREVIEW === 'true'
) {
console.warn(
'The `theme` property provided to InstUISettingsProvider is not a valid InstUI theme object.\ntheme: ',
resolvedThemeOrOverride
Expand Down
5 changes: 4 additions & 1 deletion packages/emotion/src/useTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ const useTheme = () => {
// This reads the theme from Emotion's ThemeContext
let theme = useEmotionTheme() as BaseThemeOrOverride
if (isEmpty(theme)) {
if (process.env.NODE_ENV !== 'production') {
if (
process.env.NODE_ENV !== 'production' ||
process.env.GITHUB_PULL_REQUEST_PREVIEW === 'true'
) {
console.warn(
`No theme provided for [InstUISettingsProvider], using default <canvas> theme.`
)
Expand Down
5 changes: 4 additions & 1 deletion packages/ui-babel-preset/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ module.exports = function (
)
}

if (opts.removeConsole) {
if (
process.env.GITHUB_PULL_REQUEST_PREVIEW !== 'true' &&
opts.removeConsole
) {
if (typeof opts.removeConsole === 'object') {
plugins.push([
require('babel-plugin-transform-remove-console'),
Expand Down
6 changes: 5 additions & 1 deletion packages/ui-i18n/src/textDirectionContextConsumer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,11 @@ const textDirectionContextConsumer: TextDirectionContextConsumerType =
return (
<TextDirectionContext.Consumer>
{(dir) => {
if (process.env.NODE_ENV !== 'production' && dir === 'auto') {
if (
(process.env.NODE_ENV !== 'production' ||
process.env.GITHUB_PULL_REQUEST_PREVIEW === 'true') &&
dir === 'auto'
) {
console.warn(
"'auto' is not an supported value for the 'dir' prop. Please pass 'ltr' or 'rtl'"
)
Expand Down
4 changes: 3 additions & 1 deletion packages/ui-view/src/View/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ class View extends Component<ViewProps> {

let shouldLogError = true
try {
shouldLogError = process.env.NODE_ENV !== 'production'
shouldLogError =
process.env.NODE_ENV !== 'production' ||
process.env.GITHUB_PULL_REQUEST_PREVIEW === 'true'
} catch (e) {
if (e instanceof ReferenceError) {
// if process is not available a ReferenceError is thrown
Expand Down
Loading