Skip to content

Commit

Permalink
fix backwards compatability for devOptions.out (#1342)
Browse files Browse the repository at this point in the history
  • Loading branch information
FredKSchott committed Oct 17, 2020
1 parent e7fb6ec commit 664c82e
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 2 deletions.
8 changes: 7 additions & 1 deletion snowpack/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,12 @@ function expandCliFlags(flags: CLIFlags): DeepPartial<SnowpackConfig> {
result[flag] = val;
continue;
}
// Special: we moved `devOptions.out` -> `buildOptions.out`.
// Handle that flag special here, to prevent risk of undefined matching.
if (flag === 'out') {
result.buildOptions['out'] = val;
continue;
}
if (configSchema.properties.experiments.properties[flag]) {
result.experiments[flag] = val;
continue;
Expand Down Expand Up @@ -569,7 +575,7 @@ function normalizeConfig(config: SnowpackConfig): SnowpackConfig {
);
}
// @ts-ignore
config.buildOptions.out = path.resolve(cwd, config.buildOptions.out || config.devOptions.out);
config.buildOptions.out = path.resolve(cwd, config.devOptions.out || config.buildOptions.out);
config.installOptions.rollup = config.installOptions.rollup || {};
config.installOptions.rollup.plugins = config.installOptions.rollup.plugins || [];
config.exclude = Array.from(
Expand Down
2 changes: 1 addition & 1 deletion test/build/build.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('snowpack build', () => {
const capitalize = testName === 'entrypoint-ids' && os.platform() === 'win32';
execa.sync('yarn', ['testbuild'], {cwd: capitalize ? cwd.toUpperCase() : cwd});
const actual =
testName === 'config-out' ? path.join(cwd, 'TEST_BUILD_OUT') : path.join(cwd, 'build');
testName.startsWith('config-out') ? path.join(cwd, 'TEST_BUILD_OUT') : path.join(cwd, 'build');

// Test That all files match
const allFiles = glob.sync(`**/*`, {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default {"MODE":"production","NODE_ENV":"production"};
18 changes: 18 additions & 0 deletions test/build/config-out-flag/TEST_BUILD_OUT/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"private": true,
"version": "1.0.1",
"name": "@snowpack/test-config-out-flag",
"description": "Test for --out flag",
"scripts": {
"testbuild": "snowpack build --out TEST_BUILD_OUT"
},
"snowpack": {
"exclude": [
"__snapshots__"
]
},
"devDependencies": {
"cross-env": "^7.0.2",
"snowpack": "^2.12.1"
}
}
1 change: 1 addition & 0 deletions test/build/config-out-flag/TEST_BUILD_OUT/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log('fooey');
34 changes: 34 additions & 0 deletions test/build/config-out-flag/__snapshots__
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`snowpack build config-out-flag: allFiles 1`] = `
Array [
"__snowpack__/env.js",
"package.json",
"src/index.js",
]
`;

exports[`snowpack build config-out-flag: build/__snowpack__/env.js 1`] = `"export default {\\"MODE\\":\\"production\\",\\"NODE_ENV\\":\\"production\\"};"`;

exports[`snowpack build config-out-flag: build/package.json 1`] = `
"{
\\"private\\": true,
\\"version\\": \\"1.0.1\\",
\\"name\\": \\"@snowpack/test-config-out-flag\\",
\\"description\\": \\"Test for --out flag\\",
\\"scripts\\": {
\\"testbuild\\": \\"snowpack build --out TEST_BUILD_OUT\\"
},
\\"snowpack\\": {
\\"exclude\\": [
\\"__snapshots__\\"
]
},
\\"devDependencies\\": {
\\"cross-env\\": \\"^7.0.2\\",
\\"snowpack\\": \\"^2.12.1\\"
}
}"
`;

exports[`snowpack build config-out-flag: build/src/index.js 1`] = `"console.log('fooey');"`;
18 changes: 18 additions & 0 deletions test/build/config-out-flag/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"private": true,
"version": "1.0.1",
"name": "@snowpack/test-config-out-flag",
"description": "Test for --out flag",
"scripts": {
"testbuild": "snowpack build --out TEST_BUILD_OUT"
},
"snowpack": {
"exclude": [
"__snapshots__"
]
},
"devDependencies": {
"cross-env": "^7.0.2",
"snowpack": "^2.12.1"
}
}
1 change: 1 addition & 0 deletions test/build/config-out-flag/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log('fooey');

1 comment on commit 664c82e

@vercel
Copy link

@vercel vercel bot commented on 664c82e Oct 17, 2020

Choose a reason for hiding this comment

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

Please sign in to comment.