Skip to content

Commit

Permalink
refactor: add webpack to compile to single file
Browse files Browse the repository at this point in the history
  • Loading branch information
byCedric committed May 7, 2020
1 parent cc51ef6 commit f445881
Show file tree
Hide file tree
Showing 8 changed files with 462 additions and 98 deletions.
1 change: 1 addition & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ vsc-extension-quickstart.md
**/.eslintrc.json
**/*.map
**/*.ts
webpack.config.js
17 changes: 12 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,35 @@
"*"
],
"scripts": {
"vscode:prepublish": "yarn clean && yarn build",
"vscode:prepublish": "yarn clean && yarn build:webpack",
"start": "tsc -watch -p ./",
"build": "tsc -p ./",
"build:production": "webpack --mode production",
"clean": "git clean -xdf out",
"lint": "eslint src --ext ts",
"pretest": "yarn build && yarn lint",
"test": "node ./out/test/runTest.js"
"test": "node ./out/test/runTest.js",
"lint": "eslint src --ext ts"
},
"dependencies": {
"@expo/xdl": "^57.9.2-alpha.0"
"@expo/xdl": "^57.9.1"
},
"devDependencies": {
"@babel/core": "^7.9.6",
"@expo/babel-preset-cli": "^0.2.11",
"@types/glob": "^7.1.1",
"@types/mocha": "^7.0.2",
"@types/node": "^13.11.0",
"@types/vscode": "^1.44.0",
"@typescript-eslint/eslint-plugin": "^2.30.0",
"@typescript-eslint/parser": "^2.30.0",
"babel-loader": "^8.1.0",
"eslint": "^6.8.0",
"glob": "^7.1.6",
"mocha": "^7.1.2",
"shebang-loader": "^0.0.1",
"typescript": "^3.8.3",
"vscode-test": "^1.3.0"
"vscode-test": "^1.3.0",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.11"
}
}
1 change: 0 additions & 1 deletion src/manifest/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export async function registerGlobalSchema(schemaUri: vscode.Uri) {
});

await config.update('json.schemas', newValue, vscode.ConfigurationTarget.Global);

}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/manifest/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as vscode from 'vscode';
import * as xdl from '@expo/xdl';
import * as XdlVersions from '@expo/xdl/build/Versions';
import * as Config from './config';
import * as Schema from './schema';
import * as Storage from './storage';
Expand All @@ -9,7 +9,7 @@ import * as Storage from './storage';
* This will not check if the cache has an existing one, because we always want to fetch the latest.
*/
export async function activateGlobalSchema(context: vscode.ExtensionContext) {
const latestSdk = await xdl.Versions.newestReleasedSdkVersionAsync();
const latestSdk = await XdlVersions.newestReleasedSdkVersionAsync();
const schemaFile = await Schema.getSchema(latestSdk.version);
const schemaPath = await Storage.storeSchema(context, schemaFile);
await Config.registerGlobalSchema(schemaPath);
Expand Down
4 changes: 2 additions & 2 deletions src/manifest/schema.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as xdl from '@expo/xdl';
import * as XdlExpSchema from '@expo/xdl/build/project/ExpSchema';

export interface ManifestSchema {
$schema: string,
Expand All @@ -15,7 +15,7 @@ export interface ManifestSchema {
* Fetch the XDL schema for a specific Expo SDK version.
*/
export async function getSchema(sdkVersion: string) {
const schema = await xdl.ExpSchema.getSchemaAsync(sdkVersion);
const schema = await XdlExpSchema.getSchemaAsync(sdkVersion);
return createFromXdl(sdkVersion, schema);
}

Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"extends": "@expo/babel-preset-cli/tsconfig.base",
"compilerOptions": {
"module": "commonjs",
"target": "es6",
Expand All @@ -9,7 +10,7 @@
"sourceMap": true,
"rootDir": "src",
"strict": true, /* enable all strict type-checking options */
"skipLibCheck": true
// "skipLibCheck": true
/* Additional Checks */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
Expand Down
33 changes: 33 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const path = require('path');

module.exports = {
target: 'node',
entry: './src/extension.ts',
output: {
path: path.resolve(__dirname, 'out'),
filename: 'extension.js',
libraryTarget: 'commonjs2',
devtoolModuleFilenameTemplate: '../[resource-path]'
},
devtool: 'source-map',
externals: {
vscode: 'commonjs vscode',
},
resolve: {
extensions: ['.ts', '.js', '.json'],
},
module: {
rules: [
{
loader: 'shebang-loader',
},
{
test: /\.(ts|js)$/,
loader: 'babel-loader',
options: {
presets: ['@expo/babel-preset-cli'],
},
},
],
},
};
Loading

0 comments on commit f445881

Please sign in to comment.