Skip to content

Commit 00cbaf6

Browse files
author
Rich Harris
authored
ESM compatibility (#356)
* move config.js files to config.cjs * update examples * changeset * fix lint failure, hopefully
1 parent 279a3b0 commit 00cbaf6

28 files changed

+1344
-83
lines changed

Diff for: .changeset/stale-plums-heal.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'create-svelte': patch
3+
'@sveltejs/kit': patch
4+
'@sveltejs/snowpack-config': patch
5+
---
6+
7+
Rename _.config.js to _.config.cjs
File renamed without changes.

Diff for: examples/realworld.svelte.dev/README.md

+6-8
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ npm init svelte@next my-app
1616

1717
> Note: the `@next` is temporary
1818
19-
2019
## Developing
2120

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

31-
3230
## Building
3331

34-
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.)
32+
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.)
3533

36-
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:
34+
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:
3735

38-
* [@sveltejs/adapter-node](https://github.com/sveltejs/kit/tree/master/packages/adapter-node)
39-
* [@sveltejs/adapter-static](https://github.com/sveltejs/kit/tree/master/packages/adapter-static)
40-
* [@sveltejs/adapter-netlify](https://github.com/sveltejs/kit/tree/master/packages/adapter-netlify)
41-
* ...more soon
36+
- [@sveltejs/adapter-node](https://github.com/sveltejs/kit/tree/master/packages/adapter-node)
37+
- [@sveltejs/adapter-static](https://github.com/sveltejs/kit/tree/master/packages/adapter-static)
38+
- [@sveltejs/adapter-netlify](https://github.com/sveltejs/kit/tree/master/packages/adapter-netlify)
39+
- ...more soon
File renamed without changes.
File renamed without changes.

Diff for: examples/svelte-kit-demo/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

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

5-
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).
5+
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).

Diff for: packages/create-svelte/cli/modifications/utils.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ export function update_component(cwd, filepath, replacements) {
3030
}
3131

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

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

6262
if (config.includes(pluginname)) {

Diff for: packages/create-svelte/template/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ npm run dev -- --open
3131

3232
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.)
3333

34-
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:
34+
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:
3535

3636
- [@sveltejs/adapter-node](https://github.com/sveltejs/kit/tree/master/packages/adapter-node)
3737
- [@sveltejs/adapter-static](https://github.com/sveltejs/kit/tree/master/packages/adapter-static)

Diff for: packages/create-svelte/template/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
"@sveltejs/kit": "workspace:*",
1212
"@sveltejs/snowpack-config": "workspace:*",
1313
"svelte": "^3.29.0"
14-
}
14+
},
15+
"type": "module"
1516
}

0 commit comments

Comments
 (0)