forked from bazel-contrib/rules_nodejs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add a test for the react production bundle
It's failing, see discussion in bazel-contrib#933
- Loading branch information
Showing
19 changed files
with
903 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import './environment.prod'; | ||
import * as ReactDOM from 'react-dom'; | ||
import greeting from './greeting'; | ||
|
||
ReactDOM.render(greeting, document.getElementById('root')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
import './react-fix'; | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import './environment.dev'; | ||
import * as ReactDOM from 'react-dom'; | ||
import greeting from './greeting'; | ||
|
||
ReactDOM.render(greeting, document.getElementById('root')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
(window as any).process = {env: {NODE_ENV: 'production'}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// React uses a "isomorphic" package that relies on | ||
// `process.env`, even in the browser. | ||
// Make this type available in TypeScript code. | ||
declare global { | ||
interface Window { | ||
process: {} | ||
} | ||
} | ||
// make this file a module, not a script | ||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Configure React for development mode | ||
// https://github.com/bazelbuild/rules_nodejs/issues/555 | ||
window.process = { | ||
env: {NODE_ENV: 'development'} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Configure React for production | ||
// https://github.com/bazelbuild/rules_nodejs/issues/555 | ||
window.process = { | ||
env: {NODE_ENV: 'production'} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import * as React from 'react'; | ||
|
||
const greeting = <h1>Hello, world</h1>; | ||
export default greeting; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const domino = require('domino'); | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
|
||
describe('react webapp', () => { | ||
it('works', () => { | ||
const html = fs.readFileSync(path.join(__dirname, 'index.html')); | ||
// Domino gives us enough of the DOM API that we can run our JavaScript in node rather than the | ||
// browser. That makes this test a lot faster | ||
global.window = domino.createWindow(html, '/'); | ||
global.document = global.window.document; | ||
global.navigator = global.window.navigator; | ||
// Make all Domino types available as types in the global env. | ||
Object.assign(global, domino.impl); | ||
|
||
import(path.join(__dirname, 'bundle.es2015')).then(() => {expect(global.document.body.textContent).toEqual('Hello from React!')}); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.