Skip to content

Commit

Permalink
ESM compatibility (#356)
Browse files Browse the repository at this point in the history
* move config.js files to config.cjs

* update examples

* changeset

* fix lint failure, hopefully
  • Loading branch information
Rich Harris authored Feb 1, 2021
1 parent 279a3b0 commit 00cbaf6
Show file tree
Hide file tree
Showing 28 changed files with 1,344 additions and 83 deletions.
7 changes: 7 additions & 0 deletions .changeset/stale-plums-heal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'create-svelte': patch
'@sveltejs/kit': patch
'@sveltejs/snowpack-config': patch
---

Rename _.config.js to _.config.cjs
File renamed without changes.
File renamed without changes.
14 changes: 6 additions & 8 deletions examples/realworld.svelte.dev/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ npm init svelte@next my-app

> Note: the `@next` is temporary

## Developing

Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
Expand All @@ -28,14 +27,13 @@ npm run dev
npm run dev -- --open
```


## Building

Svelte apps are built with *adapters*, which optimise your project for deployment to different environments, like [Begin](https://begin.com), [Netlify](https://www.netlify.com), [Vercel](https://vercel.com) and so on. (You can also create your own adapter — instructions TODO.)
Svelte apps are built with _adapters_, which optimise your project for deployment to different environments, like [Begin](https://begin.com), [Netlify](https://www.netlify.com), [Vercel](https://vercel.com) and so on. (You can also create your own adapter — instructions TODO.)

By default, `npm run build` will generate a Node app that you can run with `node build`. To use a different adapter, install it and update your `svelte.config.js` accordingly. The following official adapters are available:
By default, `npm run build` will generate a Node app that you can run with `node build`. To use a different adapter, install it and update your `svelte.config.cjs` accordingly. The following official adapters are available:

* [@sveltejs/adapter-node](https://github.com/sveltejs/kit/tree/master/packages/adapter-node)
* [@sveltejs/adapter-static](https://github.com/sveltejs/kit/tree/master/packages/adapter-static)
* [@sveltejs/adapter-netlify](https://github.com/sveltejs/kit/tree/master/packages/adapter-netlify)
* ...more soon
- [@sveltejs/adapter-node](https://github.com/sveltejs/kit/tree/master/packages/adapter-node)
- [@sveltejs/adapter-static](https://github.com/sveltejs/kit/tree/master/packages/adapter-static)
- [@sveltejs/adapter-netlify](https://github.com/sveltejs/kit/tree/master/packages/adapter-netlify)
- ...more soon
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/svelte-kit-demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

Place to try out [@sveltejs/app](https://github.com/sveltejs/kit). Very basic and incomplete, many things haven't yet been thought through.

To start the app in development mode do `npm run dev`. To build, use `npm run build`. This will use whichever adapter is specified in `svelte.config.js`, which will also need to be installed (or linked).
To start the app in development mode do `npm run dev`. To build, use `npm run build`. This will use whichever adapter is specified in `svelte.config.cjs`, which will also need to be installed (or linked).
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions packages/create-svelte/cli/modifications/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ export function update_component(cwd, filepath, replacements) {
}

/**
* Adds `svelte-preprocess` to `svelte.config.js`, if there's no preprocessor already.
* Adds `svelte-preprocess` to `svelte.config.cjs`, if there's no preprocessor already.
*/
export function add_svelte_prepocess_to_config(cwd) {
const file = path.join(cwd, 'svelte.config.js');
const file = path.join(cwd, 'svelte.config.cjs');
let config = fs.readFileSync(file, 'utf-8');

if (config.includes('preprocess:')) {
Expand All @@ -56,7 +56,7 @@ export function add_svelte_prepocess_to_config(cwd) {
* Adds plugin to snowpack config file, if not already present.
*/
export function add_snowpack_plugin_to_config(cwd, pluginname) {
const file = path.join(cwd, 'snowpack.config.js');
const file = path.join(cwd, 'snowpack.config.cjs');
let config = fs.readFileSync(file, 'utf-8');

if (config.includes(pluginname)) {
Expand Down
2 changes: 1 addition & 1 deletion packages/create-svelte/template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ npm run dev -- --open

Svelte apps are built with _adapters_, which optimise your project for deployment to different environments, like [Begin](https://begin.com), [Netlify](https://www.netlify.com), [Vercel](https://vercel.com) and so on. (You can also create your own adapter — instructions TODO.)

By default, `npm run build` will generate a Node app that you can run with `node build`. To use a different adapter, install it and update your `svelte.config.js` accordingly. The following official adapters are available:
By default, `npm run build` will generate a Node app that you can run with `node build`. To use a different adapter, install it and update your `svelte.config.cjs` accordingly. The following official adapters are available:

- [@sveltejs/adapter-node](https://github.com/sveltejs/kit/tree/master/packages/adapter-node)
- [@sveltejs/adapter-static](https://github.com/sveltejs/kit/tree/master/packages/adapter-static)
Expand Down
3 changes: 2 additions & 1 deletion packages/create-svelte/template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
"@sveltejs/kit": "workspace:*",
"@sveltejs/snowpack-config": "workspace:*",
"svelte": "^3.29.0"
}
},
"type": "module"
}
Loading

0 comments on commit 00cbaf6

Please sign in to comment.