Skip to content

Conversation

@SaraVieira
Copy link
Contributor

@SaraVieira SaraVieira commented Apr 28, 2019

Checlist:

  • Transpile svelte 3
  • Transpile default to version 3
  • Update logo
  • add .svelte files logo
  • Add svelte vscode extension for syntax and lint
  • Handle parsing errors
  • Make project runnable on download
  • Allow deployment to netlify (https://csb-4r00193j37.netlify.com/)
  • Show lint errors in problems tab
  • Change default svelte to be version 3

Testing sandbox: http://pr1820.cs.lbogdan.tk/s/4r00193j37

closes #1809

Also closes #1765 as I updated the sass loader

@SaraVieira SaraVieira requested a review from CompuIves April 28, 2019 11:08
@SaraVieira SaraVieira closed this Apr 28, 2019
@SaraVieira SaraVieira reopened this Apr 28, 2019
Copy link
Member

@CompuIves CompuIves left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is reaaally good! Some nitpicks, but perfectly implemented! Would be good to do a bit of backwards compat testing.

@SaraVieira SaraVieira marked this pull request as ready for review April 28, 2019 11:41
SaraVieira and others added 4 commits April 28, 2019 14:55
- Also send warnings from compiler
- Save warnings in cache and reuse them
- Optimize the VSCode svelte extension
function getV3Code(code, path) {
self.importScripts(['https://unpkg.com/[email protected]/compiler.js']);
try {
const { js, warnings } = self.svelte.compile(code, {
Copy link

@lttb lttb Apr 28, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we consider something like this?

self.importScripts(['https://unpkg.com/[email protected]']);
try {
  const explorer = cosmiconfig('svelte');
  const {config} = await explorer.search('svelte');
  if (config) ({code} = self.svelte.preprocess(code, config.preprocess));

  const { js, warnings } = self.svelte.compile(code, {
    // ...

user-side code:

svelte.config.js

const ts = require('svelte-ts-preprocess')
const sass = require('svelte-preprocess-sass')

module.exports = {
  preprocess: [ts, sass, require('./custom-preprocessor')]
}

I'm not sure that cosmiconfig will work in the browser, and maybe there are better approaches to load the config with preprocessors for codesandobx. But this kind of addition will help users set their custom svelte preprocessors (like https://github.com/ls-age/svelte-preprocess-sass or https://github.com/PaulMaly/svelte-ts-preprocess)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cosmic config doesn't seem to work in the browser :/
https://codesandbox.io/s/nnn2lmnkqm

This is an option we will do but I think we will need to check for the file ourselfs and get the data out

I am also not sure how these preprocessors will work in the browser. We have our own preprocessors for ts and sass and it would be great if we could use them :(

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It miiiight maybe work in the worker, we mock fs there and some other utils. But there is also a valid chance that it won't work. Especially since I do this 😅 : https://github.com/CompuIves/codesandbox-client/blob/b75e9969baa73478b05f49e7d8da85b08945f5ad/packages/app/config/polyfills.js#L14

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes sense to keep the simple option (maybe add some hardcoded support for sass/others) in the browser and give the option to move to a container if there is advanced configuration needed.

Copy link

@lttb lttb Apr 28, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe, besides the hardcoded support for sass and other preprocessors, it would be useful to hardcode something like require('/svelte.config.js') too? to provide an option to also add some custom preprocessors by a user. and that would be the user's responsibility, how that preprocessors work in the browser

like,

let config;

try {
  config = require('/svelte.config.js');
} catch (e) {}

try {
  if (config) ({code} = self.svelte.preprocess(code, codesandboxPreprocessors.concat(config.preprocess || [])));

  const { js, warnings } = self.svelte.compile(code, {
    // ...

@SaraVieira
Copy link
Contributor Author

YAY!

@SaraVieira SaraVieira merged commit de37da9 into master Apr 29, 2019
SaraVieira added a commit that referenced this pull request Apr 30, 2019
* add svelte3 first try

* try again

* add svelte extension; update logo

* Don't compile svelte files

* ts update

* add icon

* add SOME error handling

* fix eslint?

* Update the svelte vscode extension to have LSP

* fixes from pr review

* fix older verwsins

* Svelte Improvements

- Also send warnings from compiler
- Save warnings in cache and reuse them
- Optimize the VSCode svelte extension

* Put v3 code generation on top

* Update standalone-packages/codesandbox-browserfs/src/generic/file_index.ts

Co-Authored-By: SaraVieira <[email protected]>

* add version automacially from installed version

* make svelte app downloadable and deployable
@SaraVieira SaraVieira deleted the svelte3 branch May 14, 2019 09:52
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 this pull request may close these issues.

Update Svelte to 3.0 Error when using CSS Grid

5 participants