🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

jtaro-module

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jtaro-module - npm Package Compare versions

Comparing version
0.2.4
to
0.2.5
+5
-4
package.json
{
"name": "jtaro-module",
"version": "0.2.4",
"version": "0.2.5",
"description": "Explain the ES6 module to Es5 syntax",
"main": "index.js",
"scripts": {
"default": "node src/server.js",
"config": "node src/server.js --config=./jtaro.module.config2.js"
"default": "node src/server.js 3001",
"config": "node src/server.js --config=./jtaro.module.config2.js",
"build": "node build.js"
},

@@ -30,5 +31,5 @@ "repository": {

"rollup-plugin-babel": "^2.7.1",
"rollup-plugin-jtaro-module": "0.0.2",
"rollup-plugin-jtaro-module": "^0.1.0",
"rollup-plugin-paths": "0.0.1"
}
}

@@ -5,2 +5,6 @@ # JTaro Module

## 相关视频教程
JTaro Tutorial:[https://github.com/chjtx/JTaro-Tutorial](https://github.com/chjtx/JTaro-Tutorial)
## 前言

@@ -182,2 +186,4 @@

>tips:创建局部样式请在html文件里使用style,创建全局样式,请使用css文件
## 注意事项

@@ -184,0 +190,0 @@

@@ -1,2 +0,2 @@

/*! JTaro-Module parse.js v0.2.1 ~ (c) 2017 Author:BarZu Git:https://github.com/chjtx/JTaro-Module/ */
/*! JTaro-Module parse.js v0.2.5 ~ (c) 2017 Author:BarZu Git:https://github.com/chjtx/JTaro-Module/ */
/**

@@ -121,10 +121,10 @@ * JTaro Module

}
var s = ', [\n '
var s = ', ['
exports.forEach((item, index) => {
s += 'JTaroModules[\'' + item.name + '\']' + item.variable
if (index !== exports.length - 1) {
s += ',\n '
s += ', '
}
})
return s + '\n ]'
return s + ']'
}

@@ -144,11 +144,13 @@

function mixHeader (loaders, name) {
return '(function (f) {\n JTaroAssets[\'' + name + '\'] = 1\n' +
' var g = function () { f.apply(null' + joinImports(loaders.exports) + ')}\n ' +
loaders.imports.join('\n ') +
'\n})(function (' + joinVariables(loaders.exports) + ') {\n\n'
return '(function (f) {JTaroAssets[\'' + name + '\'] = 1;' +
'var g = function () { f.apply(null' + joinImports(loaders.exports) + ')};' +
loaders.imports.join(';') +
'})(function (' + joinVariables(loaders.exports) + ') {\n'
}
function removeImport (a, f) {
function removeImport (a, f, h) { // (imports, file, header)
var t
for (var i = 0, l = a.length; i < l; i++) {
f = f.replace(new RegExp(a[i].replace('*', '\\*') + '([\r\n]+|$)'), '')
t = i === l - 1 ? h : '\n'
f = f.replace(new RegExp(a[i].replace('*', '\\*') + '(\n|\r\n|$)'), '/* ' + a[i] + ' */' + t)
}

@@ -264,3 +266,3 @@ return f

// 去掉已转换的import
file = header + removeImport(imports, file) + '\n})'
file = removeImport(imports, file, header) + '\n})'
}

@@ -267,0 +269,0 @@

@@ -1,2 +0,2 @@

/*! JTaro-Module server.js v0.2.4 ~ (c) 2017 Author:BarZu Git:https://github.com/chjtx/JTaro-Module/ */
/*! JTaro-Module server.js v0.2.5 ~ (c) 2017 Author:BarZu Git:https://github.com/chjtx/JTaro-Module/ */
var fs = require('fs')

@@ -9,3 +9,2 @@ var path = require('path')

var configPath = './jtaro.module.config' // 默认配置文件
var showConfigError = false

@@ -20,3 +19,2 @@ // 截取命令

if (/^--config=/.test(process.argv[i])) {
showConfigError = true
configPath = process.argv[i].replace('--config=', '').replace(/^("|')|("|')$/g, '').trim()

@@ -31,72 +29,72 @@

// 使用rollupjs的插件过滤文件内容
var config
try {
config = require(configPath)
} catch (e) {
if (showConfigError) {
throw e
// 如果存在配置文件,使用rollupjs的插件过滤文件内容
var config = {}
fs.access(path.join(__dirname, configPath + '.js'), function (err) {
if (!err) {
config = require(configPath)
}
config = {}
}
runServer()
})
var mime = {
'css': 'text/css',
'gif': 'image/gif',
'html': 'text/html',
'ico': 'image/x-icon',
'jpeg': 'image/jpeg',
'jpg': 'image/jpeg',
'js': 'text/javascript',
'json': 'application/json',
'pdf': 'application/pdf',
'png': 'image/png',
'svg': 'image/svg+xml',
'swf': 'application/x-shockwave-flash',
'tiff': 'image/tiff',
'txt': 'text/plain',
'wav': 'audio/x-wav',
'wma': 'audio/x-ms-wma',
'wmv': 'video/x-ms-wmv',
'xml': 'text/xml'
}
http.createServer((req, res) => {
var parseURL = url.parse(req.url)
var pathname = parseURL.pathname
if (/\/$/.test(pathname)) {
pathname = pathname + 'index.html'
function runServer () {
var mime = {
'css': 'text/css',
'gif': 'image/gif',
'html': 'text/html',
'ico': 'image/x-icon',
'jpeg': 'image/jpeg',
'jpg': 'image/jpeg',
'js': 'text/javascript',
'json': 'application/json',
'pdf': 'application/pdf',
'png': 'image/png',
'svg': 'image/svg+xml',
'swf': 'application/x-shockwave-flash',
'tiff': 'image/tiff',
'txt': 'text/plain',
'wav': 'audio/x-wav',
'wma': 'audio/x-ms-wma',
'wmv': 'video/x-ms-wmv',
'xml': 'text/xml'
}
var ext = path.extname(pathname)
var realPath = '.' + pathname
ext = ext ? ext.slice(1) : 'unknown'
var contentType = mime[ext] || 'text/plain'
fs.stat(realPath, (err, stats) => {
if (err) {
res.writeHead(404, { 'Content-Type': 'text/plain' })
res.write('This request URL ' + pathname + ' was not found on this server.')
res.end()
} else {
fs.readFile(realPath, 'binary', function (err, file) {
if (err) {
res.writeHead(500, { 'Content-Type': 'text/plain' })
res.end(err.message)
} else {
if (ext === 'js') {
config.id = path.resolve(__dirname, config.website || '', realPath)
config.entry = path.resolve(__dirname, config.entry || '')
config.is_jtaro_module = true // 标记给rollup-plugin-paths插件使用
file = jtaroModule(file, req.url, config)
http.createServer((req, res) => {
var parseURL = url.parse(req.url)
var pathname = parseURL.pathname
if (/\/$/.test(pathname)) {
pathname = pathname + 'index.html'
}
var ext = path.extname(pathname)
var realPath = '.' + pathname
ext = ext ? ext.slice(1) : 'unknown'
var contentType = mime[ext] || 'text/plain'
fs.stat(realPath, (err, stats) => {
if (err) {
res.writeHead(404, { 'Content-Type': 'text/plain' })
res.write('This request URL ' + pathname + ' was not found on this server.')
res.end()
} else {
fs.readFile(realPath, 'binary', function (err, file) {
if (err) {
res.writeHead(500, { 'Content-Type': 'text/plain' })
res.end(err.message)
} else {
if (ext === 'js') {
config.id = path.resolve(__dirname, config.website || '', realPath)
config.entry = path.resolve(__dirname, config.entry || '')
config.is_jtaro_module = true // 标记给rollup-plugin-paths插件使用
file = jtaroModule(file, req.url, config)
}
res.writeHead(200, { 'Content-Type': contentType })
res.write(file, 'binary')
res.end()
}
})
}
})
}).listen(port)
}
res.writeHead(200, { 'Content-Type': contentType })
res.write(file, 'binary')
res.end()
}
})
}
})
}).listen(port)
console.log('JTaro Module Server run on port: ' + port)