How to use the next-server/constants.IS_BUNDLED_PAGE_REGEX.test function in next-server

To help you get started, we’ve selected a few next-server examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zeit / next.js / packages / next / build / webpack / plugins / pages-plugin.js View on Github external
compilation.moduleTemplates.javascript.hooks.render.tap('PagesPluginRenderPageRegister', (moduleSourcePostModule, module, options) => {
        const {chunk} = options

        // check if the current module is the entry module, we only want to wrap the topmost module
        if (chunk.entryModule !== module) {
          return moduleSourcePostModule
        }

        // Check if the chunk is a page
        if (!IS_BUNDLED_PAGE_REGEX.test(chunk.name)) {
          return moduleSourcePostModule
        }

        // Match the route the chunk belongs to
        let routeName = ROUTE_NAME_REGEX.exec(chunk.name)[1]

        // We need to convert \ into / when we are in windows
        // to get the proper route name
        // Here we need to do windows check because it's possible
        // to have "\" in the filename in unix.
        // Anyway if someone did that, he'll be having issues here.
        // But that's something we cannot avoid.
        if (/^win/.test(process.platform)) {
          routeName = routeName.replace(/\\/g, '/')
        }
github zeit / next.js / packages / next / server / on-demand-entry-handler.js View on Github external
.filter(e => {
        // Make sure to only pick errors which marked with missing modules
        const hasNoModuleFoundError = /ENOENT/.test(e.message) || /Module not found/.test(e.message)
        if (!hasNoModuleFoundError) return false

        // The page itself is missing. So this is a failed page.
        if (IS_BUNDLED_PAGE_REGEX.test(e.module.name)) return true

        // No dependencies means this is a top level page.
        // So this is a failed page.
        return e.module.dependencies.length === 0
      })
      .map(e => e.module.chunks)