From d0ad62339cde30b8c10725837748dfe09c1decfe Mon Sep 17 00:00:00 2001 From: yelo Date: Fri, 21 Dec 2018 22:05:53 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E7=9B=B8=E5=AF=B9?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E5=8A=A0=E8=BD=BD=20shim?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 3 ++- package.json | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 364ee09..61391f3 100644 --- a/index.js +++ b/index.js @@ -7,6 +7,7 @@ const wxsToJs = require('./lib/wxs/index') const svgToPng = require('./lib/svg/index') const fs = require('file-system') const path = require('path') +const posix = require('ensure-posix-path') // 获取文件格式 @@ -33,7 +34,7 @@ function getFilePath (filepath) { } function jsToAliHelp (relative, code) { - let destPath = path.relative(relative, 'my.shim.js').replace('../', '') + let destPath = `./${posix(path.relative(path.dirname(relative), 'my.shim.js'))}` // 追加polyfill code = `var _myShim = require('${destPath}'); diff --git a/package.json b/package.json index 026ce11..25bb25d 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "babel-core": "^6.26.0", "babel-preset-es2015": "^6.24.1", "cssdom": "^1.0.21", + "ensure-posix-path": "^1.0.2", "file-system": "^2.2.2", "htmldom": "^3.0.4" } From 240bfde465b8ed8d2912cf5b2fc803dbacd79bbe Mon Sep 17 00:00:00 2001 From: imyelo Date: Sat, 29 Dec 2018 12:51:45 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E7=9B=B8=E5=AF=B9?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E5=8A=A0=E8=BD=BD=20es.reflect?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/js/helpers.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/js/helpers.js b/lib/js/helpers.js index e7a5e69..f25132e 100644 --- a/lib/js/helpers.js +++ b/lib/js/helpers.js @@ -2,10 +2,11 @@ const template = require('@babel/template') const generate = require('@babel/generator').default const path = require('path') const defineHelper = template.program({ placeholderPattern: false }); +const posix = require('ensure-posix-path') exports.requireReflect = function (relative) { - let destPath = path.relative(relative, 'es.reflect').replace('../', '') + let destPath = `./${posix(path.relative(path.dirname(relative), 'es.reflect'))}` let result = defineHelper(`var Reflect = require('${destPath}');`)()