Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions .babelrc

This file was deleted.

17 changes: 17 additions & 0 deletions .babelrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const modules = process.env.NODE_ENV === 'test' ? 'commonjs' : false
const loose = true

module.exports = {
presets: [
["@babel/env", { modules, loose }],
["@babel/stage-0", { loose }],
"@babel/react",
"@babel/flow",
],
plugins: [
[
"module-resolver",
{"root": ["./src"]},
],
],
}
33 changes: 25 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
"homepage": "http://tasti.github.io/react-linkify/",
"author": "Tasti Zakarie",
"license": "MIT",
"main": "dist/index.js",
"main": "dist/react-linkify.cjs.js",
"module": "dist/react-linkify.es.js",
"files": [
"dist"
],
"repository": {
"type": "git",
"url": "https://github.com/tasti/react-linkify.git"
Expand All @@ -23,25 +27,38 @@
"urlify"
],
"scripts": {
"build": "babel src/ -d dist/",
"prebuild": "rimraf dist",
"build": "rollup -c",
"prepublish": "npm run build",
"test": "BABEL_JEST_STAGE=0 jest --testPathIgnorePatterns /dist/"
},
"dependencies": {
"linkify-it": "^2.0.3",
"tlds": "^1.199.0"
},
"peerDependencies": {
"react": "^16.2.0",
"react-dom": "^16.2.0"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"@babel/core": "7.0.0-beta.37",
"@babel/preset-env": "7.0.0-beta.37",
"@babel/preset-flow": "7.0.0-beta.37",
"@babel/preset-react": "7.0.0-beta.37",
"@babel/preset-stage-0": "7.0.0-beta.37",
"babel-core": "^7.0.0-0",
"babel-jest": "^22.0.4",
"babel-plugin-module-resolver": "^3.0.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-flow": "^6.23.0",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"jest": "^22.0.4",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-test-renderer": "^16.2.0"
"react-test-renderer": "^16.2.0",
"rimraf": "^2.6.2",
"rollup": "^0.53.3",
"rollup-plugin-babel": "4.0.0-beta.0",
"rollup-plugin-commonjs": "^8.2.6",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-replace": "^2.0.0",
"rollup-plugin-uglify": "^2.0.1"
}
}
75 changes: 75 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import nodeResolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs'
import babel from 'rollup-plugin-babel'
import replace from 'rollup-plugin-replace'
import uglify from 'rollup-plugin-uglify'
import { list as babelHelpersList } from '@babel/helpers';
import pkg from './package.json'

const mergeAll = objs => Object.assign({}, ...objs)

const commonPlugins = [
nodeResolve({ jsnext: true, extensions: ['.jsx', '.js'] }),
babel({
exclude: 'node_modules/**',
externalHelpersWhitelist: babelHelpersList.filter(helperName => helperName !== 'wrapNativeSuper')
}),
commonjs(),
]

const configBase = {
input: 'src/index.js',
external: Object.keys(pkg.dependencies || {}).concat(Object.keys(pkg.peerDependencies || {})),
plugins: commonPlugins,
}

const umdConfig = mergeAll([
configBase,
{
output: {
file: `dist/${ pkg.name }.js`,
format: 'umd',
name: 'ReactLinkify',
globals: { react: 'React', 'react-dom': 'ReactDOM', 'prop-types': 'PropTypes' },
},
external: Object.keys(pkg.peerDependencies || {}),
},
])

const devUmdConfig = mergeAll([
umdConfig,
{
plugins: umdConfig.plugins.concat(
replace({
'process.env.NODE_ENV': JSON.stringify('development'),
})
),
},
])

const prodUmdConfig = mergeAll([
umdConfig,
{ output: mergeAll([umdConfig.output, { file: umdConfig.output.file.replace(/\.js$/, '.min.js') }]) },
{
plugins: umdConfig.plugins.concat(
replace({
'process.env.NODE_ENV': JSON.stringify('production'),
}),
uglify({
compress: {
pure_getters: true,
unsafe: true,
unsafe_comps: true,
warnings: false,
},
})
),
},
])

const webConfig = mergeAll([
configBase,
{ output: [{ file: pkg.module, format: 'es' }, { file: pkg.main, format: 'cjs' }] },
])

export default [devUmdConfig, prodUmdConfig, webConfig]
2 changes: 1 addition & 1 deletion src/components/Linkify.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Linkify extends React.Component<Props, {}> {
return string;
}

const matches = this.props.matchDecorator(string);console.log(string, matches);
const matches = this.props.matchDecorator(string);
if (!matches) {
return string;
}
Expand Down
3 changes: 1 addition & 2 deletions src/decorators/defaultMatchDecorator.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
import LinkifyIt from 'linkify-it';
import tlds from 'tlds';

const linkify = new LinkifyIt();
linkify.tlds(tlds);
const linkify = /*#__PURE__*/ new LinkifyIt().tlds(tlds);

export default (text: string): Array<Object> => {
return linkify.match(text);
Expand Down
Loading