Skip to content

Commit

Permalink
更新使用 script 标签引用的说明
Browse files Browse the repository at this point in the history
  • Loading branch information
lmk123 committed Sep 20, 2017
1 parent d749a8d commit ec75e93
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 18 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ import * as tjs from 'translation.js'
import { translate, detect, audio } from 'translation.js'
```

注:translation.js 暂不支持直接使用 <script> 标签应用,在 Chrome 扩展/应用中使用时请考虑用 Webpack 之类的模块打包工具。

## 使用

### 获取翻译结果
Expand Down
24 changes: 12 additions & 12 deletions build/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fs.emptyDirSync(path.resolve(__dirname, '../declaration'))

// 编译 js
const rollup = require('rollup')
const uglifyJS = require('uglify-js')
// const uglifyJS = require('uglify-js')
const buble = require('rollup-plugin-buble')

rollup.rollup({
Expand All @@ -34,15 +34,15 @@ rollup.rollup({
})

// 输出 umd 格式
bundle.generate({
format: 'umd',
name: config.name,
globals: {
superagent: 'superagent'
},
banner: config.banner
}).then(({ code }) => {
fs.writeFile(config.umdOutputPath, code)
fs.writeFile(config.umdMinOutputPath, uglifyJS.minify(code, { output: { comments: /^!/ } }).code)
})
// bundle.generate({
// format: 'umd',
// name: config.name,
// globals: {
// superagent: 'superagent'
// },
// banner: config.banner
// }).then(({ code }) => {
// fs.writeFile(config.umdOutputPath, code)
// fs.writeFile(config.umdMinOutputPath, uglifyJS.minify(code, { output: { comments: /^!/ } }).code)
// })
})
2 changes: 1 addition & 1 deletion build/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const pkg = require('../package.json')

module.exports = {
input: path.resolve(__dirname, '../src/index.ts'),
name: 'Translator',
name: 'tjs',
tp: typescript({
useTsconfigDeclarationDir: true
}),
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
},
"main": "dist/translator.common.js",
"module": "dist/translator.esm.js",
"unpkg": "dist/translator.js",
"types": "declaration/src/index.d.ts",
"files": [
"src",
Expand Down Expand Up @@ -49,7 +48,7 @@
"fs-extra": "^4.0.2",
"jasmine": "^2.8.0",
"jasmine-core": "^2.8.0",
"nock": "^9.0.14",
"nock": "^9.0.17",
"nyc": "^11.2.1",
"rollup": "^0.50.0",
"rollup-plugin-buble": "^0.15.0",
Expand Down
1 change: 1 addition & 0 deletions src/api/youdao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ interface IResponse {

// NodeJS 只需要一行代码:
// require('crypto').createHash('md5').update('text to hash').digest('hex')
// TODO 在 typescript 里引用 CommonJS 模块有点问题
const md5 = require('blueimp-md5')

const link = 'https://fanyi.youdao.com'
Expand Down

0 comments on commit ec75e93

Please sign in to comment.