Browse Source

Add babel-loader to transpile to es5

feature/aio
Jerome Wu 6 years ago
parent
commit
3fa475195e
  1. 5
      examples/browser/demo.html
  2. 1524
      package-lock.json
  3. 3
      package.json
  4. 23
      scripts/webpack.config.common.js
  5. 2
      scripts/webpack.config.dev.js
  6. 2
      scripts/webpack.config.prod.js

5
examples/browser/demo.html

@ -39,11 +39,14 @@ function progressUpdate(packet){ @@ -39,11 +39,14 @@ function progressUpdate(packet){
function recognizeFile(file){
document.querySelector("#log").innerHTML = ''
const corePath = window.navigator.userAgent.indexOf("Edge") > -1
? '../../node_modules/tesseract.js-core/tesseract-core.asm.js'
: '../../node_modules/tesseract.js-core/tesseract-core.wasm.js';
const { TesseractWorker } = Tesseract;
const worker = new TesseractWorker({
corePath: '../../node_modules/tesseract.js-core/tesseract-core.wasm.js',
corePath,
});
worker.recognize(file,

1524
package-lock.json generated

File diff suppressed because it is too large Load Diff

3
package.json

@ -25,7 +25,10 @@ @@ -25,7 +25,10 @@
],
"license": "Apache-2.0",
"devDependencies": {
"@babel/core": "^7.4.5",
"@babel/preset-env": "^7.4.5",
"acorn": "^6.1.1",
"babel-loader": "^8.0.6",
"cors": "^2.8.5",
"eslint": "^5.9.0",
"eslint-config-airbnb": "^17.1.0",

23
scripts/webpack.config.common.js

@ -0,0 +1,23 @@ @@ -0,0 +1,23 @@
module.exports = {
module: {
rules: [
{
test: /\.m?js$/,
// exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: [
[
'@babel/preset-env',
{
targets: 'last 2 versions',
},
],
],
},
},
},
],
},
};

2
scripts/webpack.config.dev.js

@ -1,9 +1,11 @@ @@ -1,9 +1,11 @@
const path = require('path');
const webpack = require('webpack');
const common = require('./webpack.config.common');
const genConfig = ({
entry, filename, library, libraryTarget,
}) => ({
...common,
mode: 'development',
entry,
output: {

2
scripts/webpack.config.prod.js

@ -1,8 +1,10 @@ @@ -1,8 +1,10 @@
const path = require('path');
const common = require('./webpack.config.common');
const genConfig = ({
entry, filename, library, libraryTarget,
}) => ({
...common,
mode: 'production',
devtool: 'source-map',
entry,

Loading…
Cancel
Save