更新到babel 7 beta后,看起来像babel polyfill在捆绑之前不会转换。我更新了所有范围内的包,例如“@ babel / polyfill”:“7.0.0-beta.36”。并且导入了两个文件的导入,从导入'babel-polyfill'导入'@ babel / polyfill'。如何使用babel / pollyfill与babel env和babel 7.当使用useBuiltIns时,我应该使用babel / polyfill:'usage',带有目标吗?
.babelrc.js
conda install PIL
conda install Pillow
types.js
const nodeEnv = process.env.NODE_ENV || 'development'
let presetEnvConfig, plugins
if (nodeEnv === 'test'){
presetEnvConfig = {targets: {node: 'current'}}
plugins = ['istanbul']
} else {
presetEnvConfig = {
targets: {
browsers: ['last 2 versions', 'ie >= 11']
},
modules: false
}
plugins = ['react-hot-loader/babel']
}
const config = {
presets: [
['@babel/preset-env', presetEnvConfig],
'@babel/react',
'@babel/stage-2'
],
plugins,
}
index.js
import keyMirror from '../../../utils/keyMirror'
export default keyMirror({
Unassign: null,
Reassign: null,
QuickAssignment: null,
}, 'TagAssignmentTypes')
答案 0 :(得分:0)
更改
@ babel / stage-2 to @ babel / preset-stage-2
答案 1 :(得分:0)
@ babel / polyfill是一个包装程序包,仅包含稳定的core-js功能(在Babel 6中还包括提案)和再生器运行时/运行时的导入,这些是编译器生成器和异步函数所需的。该软件包无法提供从core-js @ 2到core-js @ 3的平滑迁移路径:为此,决定弃用@ babel / polyfill,以便单独包含核心的必需部分-js和regenerator-runtime。
代替
import "@babel/polyfill";
您应该使用这两行:
import "core-js/stable";
import "regenerator-runtime/runtime";
别忘了直接安装这些依赖项!
npm i --save core-js regenerator-runtime
答案 2 :(得分:0)
import shutil
import sys
import subprocess as subp
import win32com.client
import pythoncom
from datetime import datetime
import os
import time
def do_powerpoint(filename):
"""run external copy of self to do powerpoint stuff"""
# sys.executable is the python.exe you are using, __file__ is the
# path to this module's source and filename you pass in
return subp.call([sys.executable, __file__, filename])
def _do_powerpoint(filename):
try:
rundate = "Quote_{:%d%m%Y_%H%M%S%f}".format(datetime.now())
pythoncom.CoInitialize()
APPLICATION = win32com.client.DispatchEx("PowerPoint.Application")
APPLICATION.Visible = True # I think False is better so you dont see it pop up
path_ppt = shutil.copy(filename, "D:/{0}.pptx".format(rundate))
PRESENTATION = APPLICATION.Presentations.Open(path_ppt)
Slide1 = PRESENTATION.Slides(1)
Shape1 = Slide1.Shapes(1)
print(Shape1.AlternativeText)
for shape in Slide1.Shapes:
if shape.HasTextFrame:
shape.TextFrame.TextRange.Replace(FindWhat="#abc",ReplaceWhat="THAILAND", WholeWords=False)
if shape.AlternativeText == "1":
shape.Fill.UserPicture("D:/1.jpg")
if shape.AlternativeText == "2":
shape.Fill.UserPicture("D:/2.jpg")
if shape.AlternativeText == "3":
shape.Fill.UserPicture("D:/3.jpg")
PATH_TO_PDF = "{0}{1}{2}".format(r'd:/',rundate,'.pdf')
PRESENTATION.SaveAs(PATH_TO_PDF, 32)
'''if I remove below 4 lines, it works fine
and converts all pptx to pdf, but all instances of
powerpoint remain open and copies arent deleted, eating system resources'''
PRESENTATION.Close()
APPLICATION.Quit()
PRESENTATION = None
APPLICATION = None
os.remove(path_ppt)
return True
except Exception:
return False
if __name__ == "__main__":
_do_powerpoint(sys.argv[1]) # will raise error if no parameters