Skip to content

Commit

Permalink
* [html5] fix dist bug
Browse files Browse the repository at this point in the history
  • Loading branch information
MrRaindrop committed Aug 17, 2016
1 parent ac04b4f commit 9d102a5
Show file tree
Hide file tree
Showing 9 changed files with 173 additions and 197 deletions.
10 changes: 7 additions & 3 deletions bin/dist-browser.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,21 @@ echo ''
echo ''
echo 'packing weex-html5 for distribution...'

# src_dir=./html5
src_dir=./html5
base_dir=./dist/weex-html5
dist_dir=${base_dir}/dist

# get version of weex-html5 from subversion of main package.json.
pkg=./package.json
dist_pkg=${base_dir}/package.json
version=$( grep -o -E "\"browser\": \"([0-9.]+)\"" ${pkg} | grep -o -E "[0-9.]+" )
transformerVersion=$( grep -o -E "\"transformer\": \"([>=< 0-9.]+)\"" ${pkg} | grep -o -E "[>=< 0-9.]+")
echo "version:" ${version}
echo "availableTransfomer version:" ${transformerVersion}

# update package.json for weex-html5 package.
cat ${dist_pkg} | sed "s/\"version\": \"[0-9.]*\"/\"version\": \"${version}\"/g" > ${base_dir}/tmp.json;
cat ${dist_pkg} | sed "s/\"version\": \"[0-9.]*\"/\"version\": \"${version}\"/g" > ${base_dir}/tmp.json
# cat ${dist_pkg} | sed "s/\"version\": \"[0-9.]*\"/\"version\": \"${version}\"/g;s/\"transformer\": \"[>=< 0-9.]*\"/\"transformer\": \"${transformerVersion}\"/g" > ${base_dir}/tmp.json
rm ${dist_pkg}
mv ${base_dir}/tmp.json ${dist_pkg}

Expand All @@ -27,7 +30,8 @@ fi
mkdir $dist_dir

cp ./dist/browser.js ${dist_dir}/weex.js
cp ${dist_dir}/weex.js ${dist_dir}/weex.common.js
cp ./dist/browser.common.js ${dist_dir}/weex.common.js
# cp ${dist_dir}/weex.js ${dist_dir}/weex.common.js
echo -e "\nmodule.exports = global.weex;" >> ${dist_dir}/weex.common.js

uglifyjs ${dist_dir}/weex.js -o ${dist_dir}/weex.min.js
Expand Down
50 changes: 50 additions & 0 deletions build/webpack.common.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
var path = require('path')
var fs = require('fs')

var dirPath = path.resolve(__dirname, '..', 'html5', 'runtime')
var filePath = path.join(dirPath, 'config.js')
if (!fs.existsSync(filePath)) {
var programName = require('os').platform() === 'win32' ? 'npm.cmd' : 'npm'
require('child_process').spawnSync(programName, ['run', 'build:config'])
}

var webpack = require('webpack')

var pkg = require('../package.json')

var sourceMapPlugin = new webpack.SourceMapDevToolPlugin({
test: /\.js$/
})

var version = pkg.subversion.browser

var date = new Date().toISOString().split('T')[0].replace(/\-/g, '')
var banner = `(function(s) {console.log(s)})` +
`('START WEEX HTML5: ${version} Build ${date}');`;

var bannerPlugin = new webpack.BannerPlugin(banner, {
raw: true
})

module.exports = {
entry: './html5/browser',
output: {
path: './dist',
filename: 'browser.common.js',
},
node: {
global: false
},
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loaders: ['babel']
},
{ test: /\.json$/, loader: 'json'},
{ test: /\.css$/, loader: 'style-loader!css-loader' }
]
},
plugins: [bannerPlugin, sourceMapPlugin]
}
23 changes: 23 additions & 0 deletions dist/weex-html5/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "weex-html5",
"version": "0.3.1",
"description": "Weex HTML5 Renderer",
"main": "dist/weex.common.js",
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/alibaba/weex.git"
},
"keywords": [
"weex",
"html5"
],
"author": {
"name": "mr.raindrop"
},
"license": "Apache-2.0",
"homepage": "https://alibaba.github.io/weex",
"readmeFilename": "README.md",
"bugs": {
"url": "https://github.com/alibaba/weex/issues"
}
}
2 changes: 2 additions & 0 deletions html5/browser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ Weex.install(root)
Weex.install(div)
Weex.install(components)
Weex.install(api)

export default Weex
2 changes: 1 addition & 1 deletion html5/browser/runtime/app/bundle/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function bootstrap (app, name, config, data) {
config = isPlainObject(config) ? config : {}

console.log(`transformerVersion: ${config.transformerVersion}, `
+ `available transformerVersion: ${global.transformerVersion}`)
+ `available transformerVersion: ${global.transformVersion}`)

// if (typeof config.transformerVersion === 'string' &&
// typeof global.transformerVersion === 'string' &&
Expand Down
9 changes: 4 additions & 5 deletions html5/browser/runtime/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import './shared'
import init from './init'
import frameworks from './config'
import { Document, Element, Comment } from '../../vdom'
import { subversion } from '../../../package.json'
// import * as methods from '../../default/api/methods'
// import { subversion } from '../../../package.json'
import * as methods from '../../default/api/methods'
import Listener from '../dom/componentManager'

Expand All @@ -19,7 +18,7 @@ const config = {

const runtime = init(config)

const { native, transformer } = subversion
// const { native, transformer } = subversion

for (const methodName in runtime) {
global[methodName] = function (...args) {
Expand All @@ -31,8 +30,8 @@ for (const methodName in runtime) {
}
}

global.frameworkVersion = native
global.transformVersion = transformer
// global.frameworkVersion = native
// global.transformVersion = transformer

/**
* register methods
Expand Down
183 changes: 0 additions & 183 deletions html5/browser/runtime/weex.js

This file was deleted.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@
"postinstall": "bash ./bin/install-hooks.sh",
"build:config": "node build/config.frameworks.js",
"build:browser": "webpack --config build/webpack.browser.config.js",
"build:common": "webpack --config build/webpack.common.config.js",
"build:native": "webpack --config build/webpack.native.config.js",
"build:examples": "webpack --config build/webpack.examples.config.js",
"build:test": "webpack --config build/webpack.test.config.js",
"dist:browser": "npm run build:browser && bash ./bin/dist-browser.sh",
"dist:browser": "npm run build:browser && npm run build:common && bash ./bin/dist-browser.sh",
"dist": "npm run dist:browser",
"dev:browser": "webpack --watch --config build/webpack.browser.config.js",
"dev:native": "webpack --watch --config build/webpack.native.config.js",
Expand All @@ -58,7 +59,7 @@
"copy": "npm run copy:js && npm run copy:examples"
},
"subversion": {
"browser": "0.3.0",
"browser": "0.3.1",
"framework": "0.15.2",
"transformer": ">=0.1.5 <0.4"
},
Expand Down
Loading

0 comments on commit 9d102a5

Please sign in to comment.