Skip to content

Not allowed to load local resource -> ModuleBuildError: Module build failed -> TypeError: Failed to fetch dynamically imported module #1478

Description

@jantimon

Describe the bug

When using next-yak 0.2.1 on StackBlitz, the compilation fails due to a security error preventing the loading of a local resource.

Chrome/Brave:

Not allowed to load local resource: file:///home/projects/stackblitz-starters-bp97wq/node_modules/next-yak/dist/loaders/tsloader.js

Firefox:

Security error: Content on https://stackblitzstartersbp97wq-hlff.w-corp-staticblitz.com/iframe.70dbe416.html is not allowed to load or link file:///home/projects/stackblitz-starters-bp97wq/node_modules/next-yak/dist/loaders/tsloader.js

Safari:

[Error] Cannot load file:///home/projects/stackblitz-starters-bp97wq/node_modules/next-yak/dist/loaders/tsloader.js due to access control checks.
[Error] Failed to load resource: Cross origin requests are only supported for HTTP. (tsloader.js, line 0)

The problem arises because next-yak integrates into the Next.js config and injects a webpack loader using an absolute path (e.g., /home/projects/stackblitz-starters-bp97wq/node_modules/next-yak/dist/loaders/tsloader.js).

As soon as Next.js triggers the compilation and attempts to execute the loader, it fails due to the security restrictions in StackBlitz's environment

Link to the blitz that caused the error

https://stackblitz.com/edit/stackblitz-starters-bp97wq

Steps to reproduce

  1. Open this StackBlitz project: https://stackblitz.com/edit/stackblitz-starters-bp97wq
  2. The error occurs immediately on initial page load as the compilation is triggered.

Expected behavior

The project should compile and run successfully, as it does in a local environment

Parity with Local

Screenshots

Error in Stackblitz

Platform

Browser name  = Chrome
Full version  = 126.0.0.0
Major version = 126
navigator.appName = Netscape
navigator.userAgent = Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
performance.memory = {
  "totalJSHeapSize": 273394398,
  "usedJSHeapSize": 226013986,
  "jsHeapSizeLimit": 4294705152
}
Hash = 70dbe416

Additional context

Worked before with next-yak 0.2.0:
https://stackblitz.com/edit/stackblitz-starters-dfykqy?file=app%2Fpage.tsx

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions