Skip to content

Commit a97612d

Browse files
committed
fix: package issue.
1 parent e1c3618 commit a97612d

7 files changed

+82
-19
lines changed

.vscodeignore

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
.vscode
2-
node_modules
3-
out/
4-
src/
5-
tsconfig.json
6-
webpack.config.js
7-
webviews/
8-
.gitignore
9-
.editorconfig
10-
.prettierignore
11-
.prettierrc.js
12-
yarn.lock
1+
*
2+
*/**
3+
**/.DS_Store
4+
5+
!node_modules/vscode-nls/**/*
6+
!node_modules/got/**/*
7+
8+
!out/**/*
9+
!assets/**/*
10+
11+
!package.json
12+
!README.md

package.json

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "coding-plugin",
33
"description": "Coding plugin for VS Code.",
4-
"version": "0.2.0",
4+
"version": "0.2.1",
55
"publisher": "coding-net",
66
"license": "MIT",
77
"engines": {
@@ -120,14 +120,15 @@
120120
"postinstall": "cd src/typings && npx vscode-dts master && npx vscode-dts dev master",
121121
"vscode:prepublish": "npm run compile",
122122
"compile": "npm-run-all -p compile:*",
123-
"compile:extension": "tsc -p ./src",
124-
"compile:webviews": "webpack --config webpack.config.js",
123+
"compile:extension": "webpack --mode production --config webpack.config.extension.js",
124+
"extension:compile-raw": "tsc -p ./src",
125+
"compile:webviews": "webpack --config webpack.config.webview.js",
125126
"watch": "npm-run-all -p watch:*",
126127
"watch:extension": "tsc -watch -p ./src",
127128
"watch:webviews": "webpack --watch --mode development",
128129
"lint": "eslint . --ext .ts,.tsx",
129-
"package": "npx vsce package",
130-
"release": "npx vsce publish"
130+
"package": "npx vsce package --yarn",
131+
"release": "npx vsce publish --yarn"
131132
},
132133
"babel": {
133134
"plugins": [

src/codingServer.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ import { IRepoInfo, ISessionData, TokenType } from 'src/typings/commonTypes';
2424
import { keychain } from 'src/common/keychain';
2525
import Logger from 'src/common/logger';
2626

27+
// @ts-ignore
28+
import * as pkgInfo from '../package.json';
29+
2730
const AUTH_SERVER = `https://x5p7m.csb.app`;
2831
const ClientId = `ff768664c96d04235b1cc4af1e3b37a8`;
2932
const ClientSecret = `d29ebb32cab8b5f0a643b5da7dcad8d1469312c7`;
@@ -113,7 +116,7 @@ export class CodingServer {
113116

114117
public async startOAuth(team: string, scopes: string) {
115118
const state = nanoid();
116-
const { name, publisher } = require('../package.json');
119+
const { name, publisher } = pkgInfo;
117120
const callbackUri = await vscode.env.asExternalUri(
118121
vscode.Uri.parse(`${vscode.env.uriScheme}://${publisher}.${name}/on-did-authenticate`),
119122
);

src/extension.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'module-alias/register';
1+
// import 'module-alias/register';
22
import * as vscode from 'vscode';
33

44
import { uriHandler, CodingServer } from 'src/codingServer';

src/tsconfig.json

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
"compilerOptions": {
33
"module": "commonjs",
44
"target": "es2019",
5+
"moduleResolution": "Node",
6+
"resolveJsonModule": true,
57
"lib": ["es2019", "dom", "es2020"],
68
"outDir": "../out",
79
"sourceMap": true,

webpack.config.extension.js

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
//@ts-check
7+
8+
'use strict';
9+
10+
const path = require('path');
11+
12+
/**@type {import('webpack').Configuration}*/
13+
const config = {
14+
target: 'node', // vscode extensions run in a Node.js-context 📖 -> https://webpack.js.org/configuration/node/
15+
16+
entry: './src/extension.ts', // the entry point of this extension, 📖 -> https://webpack.js.org/configuration/entry-context/
17+
output: {
18+
// the bundle is stored in the 'dist' folder (check package.json), 📖 -> https://webpack.js.org/configuration/output/
19+
path: path.resolve(__dirname, 'out'),
20+
filename: 'extension.js',
21+
libraryTarget: 'commonjs2',
22+
devtoolModuleFilenameTemplate: '../[resource-path]',
23+
},
24+
devtool: 'source-map',
25+
externals: {
26+
vscode: 'commonjs vscode', // the vscode-module is created on-the-fly and must be excluded. Add other modules that cannot be webpack'ed, 📖 -> https://webpack.js.org/configuration/externals/
27+
got: 'got',
28+
keytar: 'keytar',
29+
},
30+
resolve: {
31+
// support reading TypeScript and JavaScript files, 📖 -> https://github.com/TypeStrong/ts-loader
32+
extensions: ['.ts', '.js'],
33+
alias: {
34+
src: path.resolve(__dirname, 'src'),
35+
},
36+
},
37+
module: {
38+
rules: [
39+
{
40+
test: /\.ts$/,
41+
exclude: /node_modules/,
42+
use: [
43+
{
44+
loader: 'ts-loader',
45+
options: {
46+
compilerOptions: {
47+
module: 'es6', // override `tsconfig.json` so that TypeScript emits native JavaScript modules.
48+
},
49+
},
50+
},
51+
],
52+
},
53+
],
54+
},
55+
};
56+
57+
module.exports = config;
File renamed without changes.

0 commit comments

Comments
 (0)