v0.9.0
Improvements
--extractErrors
has been changed to a boolean. It will just default to use a dummy URL in theErrorProd.js
component.- You can now extend TSDX's rollup configuration with
tsdx.config.js
. TSDX uses Rollup under the hood. The defaults are solid for most packages (Formik uses the defaults!). However, if you do wish to alter the rollup configuration, you can do so by creating a file calledtsdx.config.js
at the root of your project like so:
// Not transpiled with TypeScript or Babel, so use plain Es6/Node.js!
module.exports = {
// This function will run for each entry/format/env combination
rollup(config, options) {
return config; // always return a config.
},
};
The options
object contains the following:
export interface TsdxOptions {
// path to file
input: string;
// Safe name (for UMD)
name: string;
// JS target
target: 'node' | 'browser';
// Module format
format: 'cjs' | 'umd' | 'esm';
// Environment
env: 'development' | 'production';
// Path to tsconfig file
tsconfig?: string;
// Is opt-in invariant error extraction active?
extractErrors?: boolean;
// Is minifying?
minify?: boolean;
// Is this the very first rollup config (and thus should one-off metadata be extracted)?
writeMeta?: boolean;
}
Example: Adding Postcss
const postcss = require('rollup-plugin-postcss');
const autoprefixer = require('autoprefixer');
const cssnano = require('cssnano');
module.exports = {
rollup(config, options) {
config.plugins.push(
postcss({
plugins: [
autoprefixer(),
cssnano({
preset: 'default',
}),
],
inject: false,
// only write out CSS for the first bundle (avoids pointless extra files):
extract: !!options.writeMeta,
})
);
return config;
},
};
Babel
You can add your own .babelrc
to the root of your project and TSDX will merge it with its own babel transforms (which are mostly for optimization).
Commits
- Merge branch 'master' of github.com:jaredpalmer/tsdx 19c2834
- Extensible Rollup configuration (#183) cb2cf7c
- Merge branch 'master' into v0.9 a1827e4
- Merge pull request #185 from honzabrecka/update-babel-plugin-transform-async-to-promises 7bf3032
- update babel-plugin-transform-async-to-promises dependency 5838fe7
- add fixture 990f115
- document error extraction warning a7b09da
- make warning and invariant docs more descriptive 2207cee
- fix minor misunderstanding in docs 0224fac
- update docs for boolean extractErrors 111926f
- Document customization bf6731f
- Add ability to extend babel and rollup 50f2d5e
- Just default to React's url for errors by default d346cc3