Skip to content

Commit

Permalink
fix: build
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Jul 14, 2021
1 parent 4f764bb commit 7921dae
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 24 deletions.
2 changes: 2 additions & 0 deletions examples/by-features/extractions/a.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const world = 'World'
const a = `Hello ${world}`
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
"ts-loader": "^8.1.0",
"ts-mocha": "^8.0.0",
"tsconfig-paths-webpack-plugin": "^3.5.1",
"unplugin": "^0.0.2",
"uuid": "^8.3.2",
"vscode-test": "^1.5.2",
"vue": "^2.6.14",
Expand All @@ -130,8 +131,7 @@
"vuex": "^3.6.2",
"webpack": "^4.46.0",
"webpack-cli": "^3.3.12",
"webpack-filter-warnings-plugin": "^1.2.1",
"webpack-plugin-replace": "^1.2.0"
"webpack-filter-warnings-plugin": "^1.2.1"
},
"engines": {
"vscode": "^1.52.0"
Expand Down
1 change: 0 additions & 1 deletion src/core/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export class Config {
]

static ctx: ExtensionContext
static readonly debug = process.env.NODE_ENV === 'development'

static get disabled() {
return Config.getConfig<boolean>('disabled') ?? false
Expand Down
10 changes: 5 additions & 5 deletions src/env.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-expect-error
export const isProd = __PROD__
export const isDev = !isProd
// @ts-expect-error
export const isTest = __TEST__
// @ts-ignore
export const isProd: boolean = process.env.NODE_ENV === 'production'
export const isDev: boolean = !isProd
// @ts-ignore
export const isTest: boolean = process.env.NODE_ENV === 'test'
3 changes: 2 additions & 1 deletion src/protocol/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { EXT_ID } from '~/meta'
import { Commands } from '~/commands'
import { CurrentFile, Global, Config } from '~/core'
import i18n from '~/i18n'
import { isDev } from '~/env'

export interface Message {
type: string
Expand Down Expand Up @@ -36,7 +37,7 @@ export class Protocol {
get config() {
const locales = Global.loader?.locales || []
return {
debug: Config.debug,
debug: isDev,
review: Config.reviewEnabled,
locales,
flags: locales.map(i => Config.tagSystem.getFlagName(i)),
Expand Down
20 changes: 10 additions & 10 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
const path = require('path')
const FilterWarningsPlugin = require('webpack-filter-warnings-plugin')
const { TsconfigPathsPlugin } = require('tsconfig-paths-webpack-plugin')
const ReplacePlugin = require('webpack-plugin-replace')
const { createUnplugin } = require('unplugin')

/** @type {import('webpack').Configuration} */
const config = {
target: 'node',
optimization: {
minimize: false
minimize: false,
},
entry: './src/extension.ts',
output: {
Expand Down Expand Up @@ -57,15 +57,15 @@ const config = {
new FilterWarningsPlugin({
exclude: /Critical dependency: the request of a dependency is an expression/,
}),
new ReplacePlugin({
exclude: [
/node_modules/,
],
values: {
'__PROD__': process.env.NODE_ENV === 'production',
'__TEST__': process.env.NODE_ENV === 'test'
createUnplugin(() => {
return {
name: 'replace',
enforce: 'pre',
transform(code) {
return code.replace(/process\.env\.NODE_ENV/g, JSON.stringify(process.env.NODE_ENV))
}
}
})
}).webpack()
],
}

Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10812,6 +10812,11 @@ universalify@^2.0.0:
resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717"
integrity sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==

unplugin@^0.0.2:
version "0.0.2"
resolved "https://registry.yarnpkg.com/unplugin/-/unplugin-0.0.2.tgz#e185d480b80758f75eb1a5007aff8feea076ce2a"
integrity sha512-g7Yw73sCXouX+CnO5OfSfS7YsLQ9qS9Y+pQ1A3uS5EX7Pv1ob5afFViedTTosPZJKA3WUXk2pBlKcO5AuJfsxA==

unquote@~1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/unquote/-/unquote-1.1.1.tgz#8fded7324ec6e88a0ff8b905e7c098cdc086d544"
Expand Down Expand Up @@ -11150,11 +11155,6 @@ webpack-filter-warnings-plugin@^1.2.1:
resolved "https://registry.yarnpkg.com/webpack-filter-warnings-plugin/-/webpack-filter-warnings-plugin-1.2.1.tgz#dc61521cf4f9b4a336fbc89108a75ae1da951cdb"
integrity sha512-Ez6ytc9IseDMLPo0qCuNNYzgtUl8NovOqjIq4uAU8LTD4uoa1w1KpZyyzFtLTEMZpkkOkLfL9eN+KGYdk1Qtwg==

webpack-plugin-replace@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/webpack-plugin-replace/-/webpack-plugin-replace-1.2.0.tgz#3f20db96237400433231e35ea76d9be3f7128916"
integrity sha512-1HA3etHpJW55qonJqv84o5w5GY7iqF8fqSHpTWdNwarj1llkkt4jT4QSvYs1hoaU8Lu5akDnq/spHHO5mXwo1w==

webpack-sources@^1.4.0, webpack-sources@^1.4.1:
version "1.4.3"
resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.4.3.tgz#eedd8ec0b928fbf1cbfe994e22d2d890f330a933"
Expand Down

0 comments on commit 7921dae

Please sign in to comment.