Skip to content

Commit

Permalink
feat: rely on esbuild to handle process.env.NODE_ENV
Browse files Browse the repository at this point in the history
  • Loading branch information
mrgrain committed Apr 11, 2021
1 parent 35c9046 commit 04bc5ed
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 41 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ Underlying classes the power the other features. You normally won't have to use
- `bundle=true`
- `platform=browser`
- `--define:process.env.NODE_ENV=\\\"production\\\"` or actual value of `NODE_ENV` if set
> 💡 See [Static Website with React](examples/website) for a complete working example of a how to deploy a React app to S3.
Expand Down
9 changes: 0 additions & 9 deletions lib/source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,6 @@ abstract class Source<
constructor(entryPoints: string | string[], props: Props) {
const defaultOptions: Partial<BuildOptions> = {
platform: "browser",
...(!props.buildOptions?.define
? {
define: {
"process.env.NODE_ENV": `"${
process.env.NODE_ENV ?? "production"
}"`,
},
}
: {}),
};

this.props = {
Expand Down
31 changes: 0 additions & 31 deletions test/source.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,36 +129,5 @@ describe("source", () => {

expect(source.props.buildOptions.platform).toBe("browser");
});

describe("NODE_ENV is set", () => {
it("defines NODE_ENV as that value", () => {
const source = new JavaScriptSource(
"fixtures/handlers/js-handler.js"
) as any;

expect(source.props.buildOptions.define?.["process.env.NODE_ENV"]).toBe(
'"test"'
);
});
});

describe("NODE_ENV not set", () => {
beforeEach(() => {
delete process.env.NODE_ENV;
});

afterEach(() => {
process.env.NODE_ENV = "test";
});
it("defines NODE_ENV as production", () => {
const source = new JavaScriptSource(
"fixtures/handlers/js-handler.js"
) as any;

expect(source.props.buildOptions.define?.["process.env.NODE_ENV"]).toBe(
'"production"'
);
});
});
});
});

0 comments on commit 04bc5ed

Please sign in to comment.