codesandbox / codesandbox/codesandbox-client

Vanilla (Parcel): Default Open File is Unexpected / Unreliable

Open
#2,249 11 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

🤔 Improvement
Dominant language
JavaScript
Stars
13.6k
Forks
2.4k
Avg merge
6d 19h
Merged PRs (30d)
2

Description

🐛 bug report

Description of the problem

Opening a Vanilla (Parcel) sandbox, it is not clear which file will open.

I have been unable to find why this is in my quick investigation of the behavior, but starting from a fresh sandbox, its behavior can be characterized as the following through these reproduction steps:

  1. A new Vanilla (Parcel) sandbox will open src/index.js, even though it is not listed under the main field in package.json
  2. If this sandbox is forked by a user and this file removed (either with or without the reference in index.html), then the default file that will open will now be index.html
  3. If the src/styles.css file is renamed to src/index.css then this file will now be the default file to open.
  4. If the index.html file is deleted and recreated, this will again become the default file to open 😳

It seems like there should be a more clear, reliable list of default files. My suggestion would be:

  1. Optional: The last files open, if any (see #1456 below)
  2. Initial opened file setting (see #514 below)
  3. The main field in package.json

If these three configuration options are not set, I would suggest not opening any file initially.

This may also apply to other templates, potentially in different ways.

How has this issue affected you? What are you trying to accomplish?

I would like my sandboxes to have a reliable default initial file, based on clear rules.

Link to sandbox: link (optional)
Your Environment
Software Name/Version
Сodesandbox PROD-1564761038-1a9fb01ba
Browser Chrome 76.0.3809.87 (Official Build) (64-bit)
Operating System macOS Mojave 10.14.6 (18G84)
Related

Allow setting the initial opened file in sandbox.config.js: https://github.com/codesandbox/codesandbox-client/issues/514

Add sandbox configuration to change default opened file: https://github.com/codesandbox/codesandbox-client/issues/1254

Other related features:

Array syntax for main field in package.json: https://github.com/codesandbox/codesandbox-client/issues/1739

Open previously-opened files on refresh: https://github.com/codesandbox/codesandbox-client/issues/1456

Partially related:

Vanilla (Parcel) Unreliable Behavior When index.html Under Other Path (for example, in src)
https://github.com/codesandbox/codesandbox-client/issues/2240

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Trace the Vanilla (Parcel) sandbox's default-file selection using package.json, index.html, src/index.js, and src/styles.css. Reproduce the four cases, then verify that the documented precedence is applied consistently and that no file opens when no setting or main entry exists.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
developer-experience
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.