Skip to content

Commit

Permalink
Add cjs config support (#968)
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisl9029 committed Aug 31, 2020
1 parent b112148 commit 0398fc3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions docs/docs/05-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Snowpack supports configuration files in multiple formats, sorted by priority or

1. `--config [path]`: If provided.
1. `package.json`: A namespaced config object (`"snowpack": {...}`).
1. `snowpack.config.cjs`: (`module.exports = {...}`) for projects using `"type": "module"`.
1. `snowpack.config.js`: (`module.exports = {...}`).
1. `snowpack.config.json`: (`{...}`).

Expand Down
2 changes: 1 addition & 1 deletion snowpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"cachedir": "^2.3.0",
"chokidar": "^3.4.0",
"compressible": "^2.0.18",
"cosmiconfig": "^6.0.0",
"cosmiconfig": "^7.0.0",
"css-modules-loader-core": "^1.1.0",
"deepmerge": "^4.2.2",
"detect-port": "^1.3.0",
Expand Down
4 changes: 2 additions & 2 deletions snowpack/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -762,8 +762,8 @@ export function createConfiguration(

export function loadAndValidateConfig(flags: CLIFlags, pkgManifest: any): SnowpackConfig {
const explorerSync = cosmiconfigSync(CONFIG_NAME, {
// only support these 3 types of config for now
searchPlaces: ['package.json', 'snowpack.config.js', 'snowpack.config.json'],
// only support these 4 types of config for now
searchPlaces: ['package.json', 'snowpack.config.cjs', 'snowpack.config.js', 'snowpack.config.json'],
// don't support crawling up the folder tree:
stopDir: path.dirname(process.cwd()),
});
Expand Down
15 changes: 13 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5255,6 +5255,17 @@ cosmiconfig@^6.0.0:
path-type "^4.0.0"
yaml "^1.7.2"

cosmiconfig@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-7.0.0.tgz#ef9b44d773959cae63ddecd122de23853b60f8d3"
integrity sha512-pondGvTuVYDk++upghXJabWzL6Kxu6f26ljFw64Swq9v6sQPUL3EUlVDV56diOjpCayKihL6hVe8exIACU4XcA==
dependencies:
"@types/parse-json" "^4.0.0"
import-fresh "^3.2.1"
parse-json "^5.0.0"
path-type "^4.0.0"
yaml "^1.10.0"

create-ecdh@^4.0.0:
version "4.0.4"
resolved "https://registry.yarnpkg.com/create-ecdh/-/create-ecdh-4.0.4.tgz#d6e7f4bffa66736085a0762fd3a632684dabcc4e"
Expand Down Expand Up @@ -7628,7 +7639,7 @@ import-fresh@^2.0.0:
caller-path "^2.0.0"
resolve-from "^3.0.0"

import-fresh@^3.1.0:
import-fresh@^3.1.0, import-fresh@^3.2.1:
version "3.2.1"
resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.2.1.tgz#633ff618506e793af5ac91bf48b72677e15cbe66"
integrity sha512-6e1q1cnWP2RXD9/keSkxHScg508CdXqXWgWBaETNhyuBFz+kUZlKboh+ISK+bU++DmbHimVBrOz/zzPe0sZ3sQ==
Expand Down Expand Up @@ -15049,7 +15060,7 @@ yallist@^4.0.0:
resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72"
integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==

yaml@^1.7.2:
yaml@^1.10.0, yaml@^1.7.2:
version "1.10.0"
resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.0.tgz#3b593add944876077d4d683fee01081bd9fff31e"
integrity sha512-yr2icI4glYaNG+KWONODapy2/jDdMSDnrONSjblABjD9B4Z5LgiircSt8m8sRZFNi08kG9Sm0uSHtEmP3zaEGg==
Expand Down

0 comments on commit 0398fc3

Please sign in to comment.