第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會有你想問的

Webpack 將 ts 文件的導(dǎo)出編譯為空

Webpack 將 ts 文件的導(dǎo)出編譯為空

嗶嗶one 2023-11-02 22:30:56
我的 index.ts 文件中只有一行。export * from "./foo"foo.ts 文件中也只有一行。export const foo = ()=> 'bar'我只使用“npx webpack-cli init”中的默認(rèn)配置。僅編輯“模式”和“輸出”。const TerserPlugin = require('terser-webpack-plugin');module.exports = {  mode: 'production',  entry: './src/index.ts',  output:{    filename:'index.js'  },  plugins: [new webpack.ProgressPlugin()],  module: {    rules: [{      test: /\.(ts|tsx)$/,      loader: 'ts-loader',      include: [path.resolve(__dirname, 'src')],      exclude: [/node_modules/],      options:{        transpileOnly: true      }    }]  },  resolve: {    extensions: ['.tsx', '.ts', '.js']  },  optimization: {    minimizer: [new TerserPlugin()],    splitChunks: {      cacheGroups: {        vendors: {          priority: -10,          test: /[\\/]node_modules[\\/]/        }      },      chunks: 'async',      minChunks: 1,      minSize: 30000,      name: false    }  },  target:"web"}這是我的 tsconfig.js{  "compilerOptions": {    "allowSyntheticDefaultImports": false,    "noImplicitAny": true,    "module": "es6",    "target": "es5",    "allowJs": false,    "sourceMap": true  }}這是我的 package.json{  "name": "npm",  "version": "1.0.0",  "description": "",  "main": "dist/index.js",  "scripts": {    "test": "echo \"Error: no test specified\" && exit 1",    "build": "webpack"  },  "author": "",  "license": "ISC",  "devDependencies": {    "@webpack-cli/init": "^1.0.3",    "babel-plugin-syntax-dynamic-import": "^6.18.0",    "terser-webpack-plugin": "^5.0.3",    "ts-loader": "^8.0.12",    "typescript": "^4.1.2",    "webpack": "^5.10.0",    "webpack-cli": "^4.2.0"  }}當(dāng)我運(yùn)行構(gòu)建時(shí)使用這些"build": "webpack"我在“dist/index.js”中得到了一個(gè)空的index.js。我缺少什么?
查看完整描述

1 回答

?
肥皂起泡泡

TA貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超6個(gè)贊

我認(rèn)為問題在于刪除未使用的webpack. 請記住,除非傳遞給它的輸入代碼的樣式必須與配置的樣式相同,否則能夠webpack執(zhí)行此操作。esmmodule: "es6"


如果導(dǎo)出為庫,您可能必須通過指定目標(biāo)來告訴 webpack 構(gòu)建為庫,甚至可以添加名稱:


webpack.config.js


{

  output: {

    library: "yourLibName",

    libraryTarget: "umd",

    filename: "index.js"

  },

}


查看完整回答
反對 回復(fù) 2023-11-02
  • 1 回答
  • 0 關(guān)注
  • 254 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號