This repository has been archived by the owner on Dec 28, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
[Proof of Concept]: build(rollup): add experimental mode to use rollup #782
Open
tetsuharuohzeki
wants to merge
7
commits into
karen-irc:master
Choose a base branch
from
tetsuharuohzeki:rollup
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fc16abf
build(rollup): add experimental 'npm run rollup'
tetsuharuohzeki 97a5faa
build(rollup): enable to import commonjs installed by npm
tetsuharuohzeki e78ba66
build(rollup): enable to import 'jsx' file.
tetsuharuohzeki 6126c5c
build(rollup): enable babel transform
tetsuharuohzeki 2adca99
build(rollup): inject node's global objects
tetsuharuohzeki d6b058c
for debugging
tetsuharuohzeki 9737337
fix(rollup): adhoc fix to link with option-t
tetsuharuohzeki 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 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,100 @@ | ||
/// <reference path='./typings/index.d.ts'/> | ||
|
||
'use strict'; | ||
|
||
const assert = require('assert'); | ||
const path = require('path'); | ||
|
||
const nodeResolve = require('rollup-plugin-node-resolve'); | ||
const commonjs = require('rollup-plugin-commonjs'); | ||
const babel = require('rollup-plugin-babel'); | ||
const nodeGlobals = require('rollup-plugin-node-globals'); | ||
|
||
const isRelease = process.env.NODE_ENV === 'production'; | ||
|
||
const KAREN_ENTRY_POINT = process.env.KAREN_ENTRY_POINT; | ||
assert.ok(!!KAREN_ENTRY_POINT, 'not found process.env.KAREN_ENTRY_POINT'); | ||
|
||
const KAREN_CLIENT_DIST_DIR = process.env.KAREN_CLIENT_DIST_DIR; | ||
assert.ok(!!KAREN_CLIENT_DIST_DIR, 'not found process.env.KAREN_CLIENT_DIST_DIR'); | ||
|
||
const babelPresets = [ | ||
]; | ||
|
||
let babelPlugins = [ | ||
// For our target browsers, we need not some transforms. | ||
|
||
// es2016 level | ||
'babel-plugin-transform-exponentiation-operator', | ||
// es2017 level | ||
'babel-plugin-syntax-trailing-function-commas', | ||
'babel-plugin-transform-async-to-generator', | ||
|
||
// for React | ||
'syntax-jsx', | ||
'transform-react-jsx', | ||
|
||
// some utilitis | ||
'transform-inline-environment-variables', | ||
'transform-node-env-inline', | ||
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. Should we use https://github.com/rollup/rollup-plugin-replace instead of these? |
||
|
||
// to remove duplicated helper methods inserted by babel. | ||
'external-helpers', | ||
]; | ||
|
||
if (isRelease) { | ||
babelPlugins = babelPlugins.concat([ | ||
'transform-react-constant-elements', | ||
'transform-react-inline-elements', | ||
]); | ||
} | ||
else { | ||
babelPlugins = babelPlugins.concat([ | ||
'transform-react-jsx-source', | ||
]); | ||
} | ||
|
||
// https://github.com/rollup/rollup/wiki/JavaScript-API | ||
// https://github.com/rollup/rollup/wiki/Command-Line-Interface | ||
module.exports = { | ||
entry: KAREN_ENTRY_POINT, | ||
dest: path.resolve(KAREN_CLIENT_DIST_DIR, 'karen.js'), | ||
format: 'cjs', | ||
exports: 'none', | ||
useStrict: true, | ||
sourceMap: true, | ||
treeshake: true, | ||
|
||
plugins: [ | ||
// https://github.com/rollup/rollup-plugin-node-resolve | ||
nodeResolve({ | ||
module: true, | ||
main: true, | ||
browser: true, // for browser | ||
preferBuiltins: false, // linking for browser | ||
|
||
// rollup does not have 'extensions' option, | ||
// so we need to specify this option at here to import jsx file. | ||
extensions: ['.js', '.jsx'], | ||
}), | ||
|
||
// https://github.com/rollup/rollup-plugin-commonjs | ||
commonjs({ | ||
include: 'node_modules/**', | ||
ignoreGlobal: true, | ||
namedExports: { | ||
'node_modules/option-t/src/index.js': ['Some', 'None', 'OptionBase'], // FIXME | ||
}, | ||
}), | ||
|
||
// https://github.com/rollup/rollup-plugin-babel | ||
babel({ | ||
exclude: 'node_modules/**', | ||
presets: babelPresets, | ||
plugins: babelPlugins, | ||
}), | ||
|
||
// https://github.com/calvinmetcalf/rollup-plugin-node-builtins | ||
nodeGlobals(), | ||
] | ||
}; |
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
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.
update packages to latest