Skip to content

Commit

Permalink
fix: package issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
cangzhang committed Dec 15, 2020
1 parent e1c3618 commit a97612d
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 19 deletions.
24 changes: 12 additions & 12 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
.vscode
node_modules
out/
src/
tsconfig.json
webpack.config.js
webviews/
.gitignore
.editorconfig
.prettierignore
.prettierrc.js
yarn.lock
*
*/**
**/.DS_Store

!node_modules/vscode-nls/**/*
!node_modules/got/**/*

!out/**/*
!assets/**/*

!package.json
!README.md
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "coding-plugin",
"description": "Coding plugin for VS Code.",
"version": "0.2.0",
"version": "0.2.1",
"publisher": "coding-net",
"license": "MIT",
"engines": {
Expand Down Expand Up @@ -120,14 +120,15 @@
"postinstall": "cd src/typings && npx vscode-dts master && npx vscode-dts dev master",
"vscode:prepublish": "npm run compile",
"compile": "npm-run-all -p compile:*",
"compile:extension": "tsc -p ./src",
"compile:webviews": "webpack --config webpack.config.js",
"compile:extension": "webpack --mode production --config webpack.config.extension.js",
"extension:compile-raw": "tsc -p ./src",
"compile:webviews": "webpack --config webpack.config.webview.js",
"watch": "npm-run-all -p watch:*",
"watch:extension": "tsc -watch -p ./src",
"watch:webviews": "webpack --watch --mode development",
"lint": "eslint . --ext .ts,.tsx",
"package": "npx vsce package",
"release": "npx vsce publish"
"package": "npx vsce package --yarn",
"release": "npx vsce publish --yarn"
},
"babel": {
"plugins": [
Expand Down
5 changes: 4 additions & 1 deletion src/codingServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ import { IRepoInfo, ISessionData, TokenType } from 'src/typings/commonTypes';
import { keychain } from 'src/common/keychain';
import Logger from 'src/common/logger';

// @ts-ignore
import * as pkgInfo from '../package.json';

const AUTH_SERVER = `https://x5p7m.csb.app`;
const ClientId = `ff768664c96d04235b1cc4af1e3b37a8`;
const ClientSecret = `d29ebb32cab8b5f0a643b5da7dcad8d1469312c7`;
Expand Down Expand Up @@ -113,7 +116,7 @@ export class CodingServer {

public async startOAuth(team: string, scopes: string) {
const state = nanoid();
const { name, publisher } = require('../package.json');
const { name, publisher } = pkgInfo;
const callbackUri = await vscode.env.asExternalUri(
vscode.Uri.parse(`${vscode.env.uriScheme}://${publisher}.${name}/on-did-authenticate`),
);
Expand Down
2 changes: 1 addition & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'module-alias/register';
// import 'module-alias/register';
import * as vscode from 'vscode';

import { uriHandler, CodingServer } from 'src/codingServer';
Expand Down
2 changes: 2 additions & 0 deletions src/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"compilerOptions": {
"module": "commonjs",
"target": "es2019",
"moduleResolution": "Node",
"resolveJsonModule": true,
"lib": ["es2019", "dom", "es2020"],
"outDir": "../out",
"sourceMap": true,
Expand Down
57 changes: 57 additions & 0 deletions webpack.config.extension.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

//@ts-check

'use strict';

const path = require('path');

/**@type {import('webpack').Configuration}*/
const config = {
target: 'node', // vscode extensions run in a Node.js-context 📖 -> https://webpack.js.org/configuration/node/

entry: './src/extension.ts', // the entry point of this extension, 📖 -> https://webpack.js.org/configuration/entry-context/
output: {
// the bundle is stored in the 'dist' folder (check package.json), 📖 -> https://webpack.js.org/configuration/output/
path: path.resolve(__dirname, 'out'),
filename: 'extension.js',
libraryTarget: 'commonjs2',
devtoolModuleFilenameTemplate: '../[resource-path]',
},
devtool: 'source-map',
externals: {
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/
got: 'got',
keytar: 'keytar',
},
resolve: {
// support reading TypeScript and JavaScript files, 📖 -> https://github.com/TypeStrong/ts-loader
extensions: ['.ts', '.js'],
alias: {
src: path.resolve(__dirname, 'src'),
},
},
module: {
rules: [
{
test: /\.ts$/,
exclude: /node_modules/,
use: [
{
loader: 'ts-loader',
options: {
compilerOptions: {
module: 'es6', // override `tsconfig.json` so that TypeScript emits native JavaScript modules.
},
},
},
],
},
],
},
};

module.exports = config;
File renamed without changes.

0 comments on commit a97612d

Please sign in to comment.