Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: port setting in haul.config.js not used #623

Merged
merged 1 commit into from
Aug 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions fixtures/react_native_with_haul_0_60x_ts/haul.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { withPolyfills, makeConfig } from "../../packages/haul-preset-0.60";

export default makeConfig({
server: {
port: 8000
},
bundles: {
index: {
entry: withPolyfills('./index'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ describe('packager server', () => {
let instance: Instance;

beforeAll(done => {
instance = startServer(8081, TEST_PROJECT_DIR, done);
// server port is set in haul.config.js fort this project
instance = startServer(undefined, TEST_PROJECT_DIR, done);
});

afterAll(() => {
Expand All @@ -27,7 +28,7 @@ describe('packager server', () => {
});

async function testPlatform(platform: string) {
const res = await fetch(`http://localhost:8081/index.${platform}.bundle`);
const res = await fetch(`http://localhost:8000/index.${platform}.bundle`);
const bundle = await res.text();
expect(bundle).toMatch('__webpack_require__');
}
5 changes: 2 additions & 3 deletions integration_tests/utils/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@ export type Instance = {
};

export function startServer(
port: number,
port: number | undefined,
projectDir: string,
done: jest.DoneCallback
) {
run(`${yarnCommand} --mutex network`, projectDir);

const server = runHaul(projectDir, [
'start',
'--port',
port.toString(),
...(port ? ['--port', port.toString()] : []),
]) as Instance['server'];
const instance: Instance = {
server,
Expand Down
4 changes: 1 addition & 3 deletions packages/haul-cli/src/commands/start.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import yargs from 'yargs';
import {
DEFAULT_PORT,
DEFAULT_CONFIG_FILENAME,
INTERACTIVE_MODE_DEFAULT,
getProjectConfigPath,
Expand All @@ -22,7 +21,6 @@ export default function startCommand(runtime: Runtime) {
builder: {
port: {
description: 'Port to run your webpack server',
default: DEFAULT_PORT,
Copy link
Member

Choose a reason for hiding this comment

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

why removing from here? I guess it's still normalized later, but this feels like a proper place for a default port

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The thing is if I add it here the port from haul.config.js won't be picked up. Also we use port from the normalised config and there's a fallback to DEFAULT_PORT there as well:

port: env.port || get(projectConfig, 'server.port', DEFAULT_PORT),

Copy link
Member

Choose a reason for hiding this comment

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

Ah yea that's a fair call

type: 'number',
},
dev: {
Expand Down Expand Up @@ -58,7 +56,7 @@ export default function startCommand(runtime: Runtime) {
},
async handler(
argv: yargs.Arguments<{
port: number;
port?: number;
dev: boolean;
interactive?: boolean;
minify?: boolean;
Expand Down