Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

process.env.NODE_ENV !== "production" statements in output makes it incompatible in browser #2603

Closed
1 of 3 tasks
baptisteArno opened this issue Jun 26, 2024 · 0 comments
Closed
1 of 3 tasks

Comments

@baptisteArno
Copy link

baptisteArno commented Jun 26, 2024

Description

When I bundle a package that imports @ark-ui/solid with the following Rollup config:

import resolve from '@rollup/plugin-node-resolve'
import terser from '@rollup/plugin-terser'
import { babel } from '@rollup/plugin-babel'
import postcss from 'rollup-plugin-postcss'
import autoprefixer from 'autoprefixer'
import tailwindcss from 'tailwindcss'
import typescript from '@rollup/plugin-typescript'
import { typescriptPaths } from 'rollup-plugin-typescript-paths'
import fs from 'fs'

const extensions = ['.ts', '.tsx']

const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'))
const packageVersion = packageJson.version
const preamble = `// v${packageVersion}`

const indexConfig = {
  input: './src/index.ts',
  output: {
    file: 'dist/index.js',
    format: 'es',
  },
  onwarn,
  plugins: [
    resolve({ extensions }),
    babel({
      babelHelpers: 'bundled',
      exclude: 'node_modules/**',
      presets: ['solid', '@babel/preset-typescript'],
      extensions,
    }),
    typescriptPaths({ preserveExtensions: true }),
    typescript(),
    postcss({
      plugins: [autoprefixer(), tailwindcss()],
      extract: false,
      modules: false,
      autoModules: false,
      minimize: true,
      inject: false,
    }),
    terser({
      format: { preamble },
    }),
  ],
}

const configs = [
  indexConfig,
  {
    ...indexConfig,
    input: './src/web.ts',
    output: {
      file: 'dist/web.js',
      format: 'es',
    },
  },
]

function onwarn(warning, warn) {
  if (
    warning.code === 'CIRCULAR_DEPENDENCY' &&
    warning.ids.some((id) => id.includes('@internationalized+date'))
  ) {
    return
  }

  warn(warning.message)
}

export default configs

The produced web.js file contains process.env.NODE_ENV !== "production" statements that come directly from the dist files from ark solid package.

When importing that file as a module in a browser, it will say "process is not defined"

Link to Reproduction (or Detailed Explanation)

https://github.com/baptisteArno/typebot.io

Steps to Reproduce

  1. cd to packages/embeds/js
  2. Build pnpm run build
  3. Inspect web.js package

Ark UI Version

3.3.0

Framework

  • React
  • Solid
  • Vue

Browser

No response

Additional Information

No response

@chakra-ui chakra-ui locked and limited conversation to collaborators Jun 27, 2024
@segunadebayo segunadebayo converted this issue into discussion #2609 Jun 27, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant