This repository was archived by the owner on Mar 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 53
chore(mixed): fix imports and introduce bundler test #570
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
07fa488
chore(mixed): fix imports and introduce bundler test
layershifter 0d58036
revert import change
layershifter 2b7a4dd
do not build dll on build:dist
layershifter 1929f00
rewrite bundler task
layershifter a9683e2
restore imports, introduce transformer
layershifter 363d3b4
fix CI command
layershifter aa8ed3b
Merge branch 'master' of https://github.com/stardust-ui/react into ch…
layershifter 8b8a748
restore command
layershifter 7b9987d
add entry
layershifter d567968
Merge branch 'master' of https://github.com/stardust-ui/react into ch…
layershifter abbf734
Merge branches 'chore/fix-imports' and 'master' of https://github.com…
layershifter 34c32b0
remove transformer
layershifter a7deb19
add typings, fix import
layershifter da99b8d
fix typo
layershifter a2cef68
review improvements
layershifter a105f7e
Merge branch 'master' of https://github.com/stardust-ui/react into ch…
layershifter 09d2dd6
update directory structure
layershifter 38770f4
Merge branch 'master' of https://github.com/stardust-ui/react into ch…
layershifter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,7 @@ | ||
import * as debug from 'debug' | ||
import * as fs from 'fs' | ||
import { task } from 'gulp' | ||
import { series, task } from 'gulp' | ||
import * as path from 'path' | ||
import sh from '../sh' | ||
import * as rimraf from 'rimraf' | ||
|
||
|
@@ -15,12 +17,13 @@ const log = msg => { | |
console.log('='.repeat(80)) | ||
} | ||
|
||
const runIn = path => cmd => sh(`cd ${path} && ${cmd}`) | ||
export const createPackageFilename = () => tmp.tmpNameSync({ prefix: 'stardust-', postfix: '.tgz' }) | ||
|
||
const buildAndPackStardust = async (): Promise<string> => { | ||
await sh('yarn build:dist') | ||
export const runIn = path => cmd => sh(`cd ${path} && ${cmd}`) | ||
|
||
return (await sh(`npm pack`, true)).trim() | ||
export const buildAndPackStardust = async (packageFilename: string) => { | ||
await sh('yarn build:dist') | ||
await sh(`yarn pack --filename ${packageFilename}`) | ||
layershifter marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
const createReactApp = async (atTempDirectory: string, appName: string): Promise<string> => { | ||
|
@@ -90,8 +93,10 @@ export default App; | |
//////// PREPARE STARDUST PACKAGE /////// | ||
log('STEP 0. Preparing Stardust package..') | ||
|
||
const stardustPackageFilename = await buildAndPackStardust() | ||
log(`Stardust package is published: ${paths.base(stardustPackageFilename)}`) | ||
const packageFilename = createPackageFilename() | ||
|
||
await buildAndPackStardust(packageFilename) | ||
log(`Stardust package is published: ${packageFilename}`) | ||
|
||
try { | ||
//////// CREATE TEST REACT APP /////// | ||
|
@@ -107,7 +112,7 @@ export default App; | |
//////// ADD STARDUST AS A DEPENDENCY /////// | ||
log('STEP 2. Add Stardust dependency to test project..') | ||
|
||
await runInTestApp(`yarn add ${paths.base(stardustPackageFilename)}`) | ||
await runInTestApp(`yarn add ${packageFilename}`) | ||
log("Stardust is successfully added as test project's dependency.") | ||
|
||
//////// REFERENCE STARDUST COMPONENTS IN TEST APP's MAIN FILE /////// | ||
|
@@ -120,6 +125,49 @@ export default App; | |
|
||
log('Test project is built successfully!') | ||
} finally { | ||
fs.unlinkSync(stardustPackageFilename) | ||
fs.unlinkSync(packageFilename) | ||
} | ||
}) | ||
|
||
task('test:projects:rollup', async () => { | ||
const logger = debug('bundle:rollup') | ||
logger.enabled = true | ||
|
||
const packageFilename = createPackageFilename() | ||
const scaffoldPath = paths.base.bind(null, 'build/gulp/tasks/test-projects/rollup') | ||
|
||
await buildAndPackStardust(packageFilename) | ||
logger(`✔️Stardust UI package was prepared: ${packageFilename}`) | ||
|
||
const tmpDirectory = tmp.dirSync({ prefix: 'stardust-' }).name | ||
logger(`✔️Temporary directory was created: ${tmpDirectory}`) | ||
|
||
const dependencies = [ | ||
'rollup', | ||
'rollup-plugin-replace', | ||
'rollup-plugin-commonjs', | ||
'rollup-plugin-node-resolve', | ||
'react', | ||
'react-dom', | ||
].join(' ') | ||
await runIn(tmpDirectory)(`yarn add ${dependencies}`) | ||
logger(`✔️Dependencies were installed`) | ||
|
||
await runIn(tmpDirectory)(`yarn add ${packageFilename}`) | ||
logger(`✔️Stardust UI was added to dependencies`) | ||
|
||
fs.copyFileSync(scaffoldPath('app.js'), path.resolve(tmpDirectory, 'app.js')) | ||
fs.copyFileSync(scaffoldPath('rollup.config.js'), path.resolve(tmpDirectory, 'rollup.config.js')) | ||
logger(`✔️Source and bundler's config were created`) | ||
|
||
await runIn(tmpDirectory)(`yarn rollup -c`) | ||
logger(`✔️Example project was successfully built: ${tmpDirectory}`) | ||
}) | ||
|
||
task( | ||
'test:projects', | ||
series( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. actually, can we run them in parallel? It seems that there is no shared state between these tasks There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will left it as is for now. When this task will be enabled, we will able to test that it works in parallel. However, I almost sure that it will work. |
||
// 'test:projects:cra-ts', Temporary disabled | ||
'test:projects:rollup', | ||
), | ||
) |
This file contains hidden or 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,12 @@ | ||
import React from 'react' | ||
import ReactDOM from 'react-dom' | ||
import { Button, Provider, themes } from '@stardust-ui/react' | ||
|
||
ReactDOM.render( | ||
React.createElement( | ||
Provider, | ||
{ theme: themes.teams }, | ||
React.createElement(Button, { content: 'Theming' }), | ||
), | ||
document.getElementById('root'), | ||
) |
This file contains hidden or 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,67 @@ | ||
import replace from 'rollup-plugin-replace' | ||
import resolve from 'rollup-plugin-node-resolve' | ||
import commonjs from 'rollup-plugin-commonjs' | ||
|
||
const warningWhitelist = [ | ||
'THIS_IS_UNDEFINED', // comes from TS transforms | ||
'CIRCULAR_DEPENDENCY', // we should fix all other circular imports | ||
'UNUSED_EXTERNAL_IMPORT', // to avoid throw on unused externals | ||
] | ||
|
||
export default { | ||
external: [ | ||
'lodash', | ||
'lodash/fp', | ||
'prop-types', | ||
'react', | ||
'react-dom', | ||
'react-is', | ||
], | ||
input: 'app.js', | ||
onwarn: (warning, warn) => { | ||
if (warningWhitelist.includes(warning.code)) { | ||
warn(warning) | ||
return | ||
} | ||
|
||
throw warning | ||
}, | ||
output: { | ||
file: 'bundle.js', | ||
format: 'iife', | ||
globals: { | ||
lodash: '_', | ||
'lodash/fp': 'fp', | ||
'prop-types': 'PropTypes', | ||
react: 'React', | ||
'react-dom': 'ReactDOM', | ||
'react-is': 'ReactIs', | ||
}, | ||
sourcemap: true, | ||
}, | ||
plugins: [ | ||
replace({ | ||
'process.env.NODE_ENV': JSON.stringify('development'), | ||
}), | ||
resolve(), | ||
commonjs({ | ||
include: 'node_modules/**', | ||
namedExports: { | ||
'node_modules/keyboard-key/src/keyboardKey.js': [ | ||
'ArrowDown', | ||
'ArrowUp', | ||
'ArrowLeft', | ||
'ArrowRight', | ||
'End', | ||
'Enter', | ||
'Escape', | ||
'Home', | ||
'getCode', | ||
'Spacebar', | ||
'Tab', | ||
], | ||
'node_modules/what-input/dist/what-input.js': ['ask'], | ||
}, | ||
}), | ||
], | ||
} |
2 changes: 1 addition & 1 deletion
2
docs/src/prototypes/chatMessageWithPopover/ChatMessageWithPopover.tsx
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍