Comments (1)
After investigating this issue, I've observed that the same error occurs in CodeSandbox. This suggests that the problem needs to be addressed in the codesandbox-client repository.
I attempted to debug locally by logging to the console, but encountered difficulties running the project. As a result, I'm sharing the code sections that I suspect may be related to the issue:
1. Remote Module Fetching
async function fetchRemoteModule(url: string): Promise<IRemoteModuleResult> {
try {
const r = await fetchWithRetries(url);
if (!r.ok) {
throw new Error(`Fetching ESModule return error status ${r.status}`);
}
const content = await r.text();
return {
url: r.url,
content,
};
} catch (err) {
console.error(err);
throw new ModuleNotFoundError(url, true);
}
}
Potential solution
The fetchWithRetries
function accepts a second argument for fetch's requestInit. We could add encoding-related logic there.
2. File Evaluation
export function evaluateFromPath(
fs: any,
BFSRequire: Function,
path: string,
currentPath: string,
availablePlugins: Object,
availablePresets: Object
) {
const resolvedPath = patchedResolve().sync(path, {
filename: currentPath,
extensions: ['.cjs', '.js', '.json'],
});
const code = fs.readFileSync(resolvedPath).toString();
return evaluate(
fs,
BFSRequire,
code,
resolvedPath,
availablePlugins,
availablePresets
);
}
Potential solution
Encoding issues might arise during file reading. We could use the detect-character-encoding
library (or implement custom logic) to identify the character encoding, then use iconv-lite
to convert it to UTF-8.
It seems that identifying the correct locations for encoding handling is key to resolving this issue. Your insights on this would be greatly appreciated. @danilowoz 🙏
from sandpack.
Related Issues (20)
- how can I keep the sandbox from refreshing while switching routes
- Documentation: Prettier example HOT 1
- Nextjs-ts HOT 1
- Get all code files HOT 2
- Transitive dependancy conflict with React 18 HOT 1
- Editor is not directly tab key activable
- Documentation: Iframe Drop target
- Documentation: useSandpackClient HOT 1
- Scrollbar artifact appearing on SandpackPreview HOT 1
- CodeEditor toggling readOnly breaks in Nextjs 14+ HOT 2
- Race condition when programmatically updating files during recompile
- XR support in preview frame
- CodeMirror decorators are not applied in the SandpackPreview component HOT 1
- How to import Omi Framework: React is not defined Error HOT 1
- Sandpack Next.js Template Fetch With Body Fails
- local: http://127.0.0.1:3002, Some resources always fail to load HOT 3
- SandPack test Runs Forever, It used to work but not anymore HOT 2
- Couldn't connect to server HOT 1
- Unable to establish connection with the sandpack bundler.
- change code will triggle npm fetch twice
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sandpack.