Skip to content
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

Don't include process in build #1046

Closed
kai687 opened this issue Sep 19, 2021 · 2 comments · Fixed by #1047
Closed

Don't include process in build #1046

kai687 opened this issue Sep 19, 2021 · 2 comments · Fixed by #1047

Comments

@kai687
Copy link
Contributor

kai687 commented Sep 19, 2021

Description

I struggled to use DocSearch@alpha via CDN.
It's because the built versions contain references to process, which isn't defined in a browser environment.

With a build tool, you can replace it, as @Haroenv mentioned in #980, but if I use it via CDN,
I have to include another code snippet:

const process = {
  env: {
    NODE_ENV: "production"
  }
}

Steps to reproduce

Here's a minimal example:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Testing DocSearch 3.0 alpha from CDN</title>
  <script src="https://cdn.jsdelivr.net/npm/@docsearch/js@alpha"></script>
</head>
<body>
  <div id="container"></div>
  <script>
    /* const process = {
      env: {
        NODE_ENV: "production"
      }
    } */
    docsearch({
      container: '#container',
      apiKey: '25626fae796133dc1e734c6bcaaeac3c',
      indexName: 'docsearch',
      debug: true,
    })
  </script>
  
</body>
</html>

uncomment the const process ... part and it should work.

Expected behavior

It would be nice to just be able to use this version of Docsearch without having to mock process.

Environment

  • DocSearch version: 3.0.0-alpha-40
@shortcuts
Copy link
Member

Thanks for the detailed issue @kai687!

I've provided a fix in #1047 and will let you know once the new version has been released!

@imageslr
Copy link

Encountered the same issue. Thanks for your solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants