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

buildSandboxGlobals doesn't seem to be called when generating pages. #76

Closed
arenoir opened this issue Mar 15, 2023 · 0 comments · Fixed by #78
Closed

buildSandboxGlobals doesn't seem to be called when generating pages. #76

arenoir opened this issue Mar 15, 2023 · 0 comments · Fixed by #78

Comments

@arenoir
Copy link

arenoir commented Mar 15, 2023

We successfully use fastboot with our ember app. However when trying to implement prember we are getting the following error.

TypeError: URL is not a constructor

We are adding the URL constructor to fastboot using the config/fastboot.js file exporting a buildSandboxGlobals function.

const { URL, URLSearchParams } = require('url');

module.exports = function () {
  return {
    buildSandboxGlobals(defaultGlobals) {
      console.log('buildSandboxGlobals')
      console.log('defaultGlobals', defaultGlobals)
      console.log('URL', new URL('https://google.com'));

      return Object.assign({}, defaultGlobals, {
        URL,
        URLSearchParams
      });
    }
  };
};

When rendering the site in fastboot everything renders, the buildSandboxGlobals function logs the defaultGlobals and the URL constructor works:

App is being served by FastBoot
buildSandboxGlobals
defaultGlobals {
  FastBoot: {
    require: [Function (anonymous)],
    config: [Function: fastbootConfig],
    distPath: [Getter]
  }
}
URL URL {
  href: 'https://google.com/',
  origin: 'https://google.com',
  protocol: 'https:',
  username: '',
  password: '',
  host: 'google.com',
  hostname: 'google.com',
  port: '',
  pathname: '/',
  search: '',
  searchParams: URLSearchParams {},
  hash: ''
}

When enabling prember we get the following error and no console statements from the buildSandboxGlobals function.

   TypeError: URL is not a constructor

    broccoliNode: {
      nodeName: 'prember',
      nodeAnnotation: undefined,
     ...
    },
    versions: { 'broccoli-builder': '3.5.2', node: 'v16.14.0' }

Any help is greatly appreciated.

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.

1 participant