-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from JennieJi/fix-release
Fix release, replace dynamic loading parser, pack source
- Loading branch information
Showing
17 changed files
with
2,415 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
"name": "Jennie Ji", | ||
"email": "[email protected]" | ||
}, | ||
"version": "0.1.1", | ||
"version": "0.1.3", | ||
"license": "MIT", | ||
"engines": { | ||
"vscode": "^1.42.0" | ||
|
@@ -74,9 +74,11 @@ | |
"startingVersion": "v0.1.0" | ||
}, | ||
"scripts": { | ||
"vscode:prepublish": "yarn changelog && yarn run compile", | ||
"vscode:prepublish": "yarn fetch:parser && yarn changelog && yarn run compile", | ||
"changelog": "auto-changelog && git add CHANGELOG.md", | ||
"compile": "tsc -p ./", | ||
"fetch:parser": "node ./scripts/fetchParsers.js", | ||
"compile": "webpack --mode production -p", | ||
"dev": "webpack --mode development -p", | ||
"lint": "eslint src --ext ts", | ||
"watch": "tsc -watch -p ./", | ||
"pretest": "yarn run compile && yarn run lint", | ||
|
@@ -98,9 +100,15 @@ | |
"eslint-plugin-prettier": "^3.1.3", | ||
"glob": "^7.1.6", | ||
"mocha": "^7.1.0", | ||
"pacote": "^11.1.10", | ||
"prettier": "^2.0.5", | ||
"shebang-loader": "^0.0.1", | ||
"ts-loader": "^7.0.5", | ||
"ts-node": "^8.10.1", | ||
"typescript": "^3.7.5", | ||
"vscode-test": "^1.3.0" | ||
"vscode-test": "^1.3.0", | ||
"webpack": "^4.43.0", | ||
"webpack-cli": "^3.3.11" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
|
@@ -110,7 +118,6 @@ | |
"url": "https://github.com/JennieJi/vscode-babel-ast-explorer/issues" | ||
}, | ||
"dependencies": { | ||
"pacote": "^11.1.10", | ||
"semver": "^7.3.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const { packument, extract } = require('pacote'); | ||
const semver = require('semver'); | ||
const path = require('path'); | ||
|
||
const PACKAGE = '@babel/parser'; | ||
|
||
function parserPath(version = '') { | ||
return path.resolve(__dirname, '../resources', PACKAGE, version); | ||
} | ||
|
||
async function getParserVersions() { | ||
const data = await packument(PACKAGE); | ||
return semver.rsort(Object.values(data.versions).map((d) => d.version)); | ||
} | ||
|
||
function resolveVersion(version = 'latest') { | ||
const spec = `${PACKAGE}@${version}`; | ||
const dist = parserPath(version); | ||
return extract(spec, dist).then((res) => { | ||
console.log(`fetched ${spec} -> ${dist}`); | ||
return res; | ||
}); | ||
} | ||
|
||
getParserVersions().then((versions) => | ||
Promise.all(versions.map(resolveVersion)) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
import { packument, extract } from 'pacote'; | ||
import * as semver from 'semver'; | ||
import * as path from 'path'; | ||
import * as fs from 'fs'; | ||
|
||
const PACKAGE = '@babel/parser'; | ||
|
||
export async function getParserVersions() { | ||
const data = await packument(PACKAGE); | ||
return semver.rsort(Object.values(data.versions).map((d) => d.version)); | ||
function parserPath(version = '') { | ||
return path.resolve(__ASSET_PATH__, PACKAGE, version); | ||
} | ||
|
||
export function parserPath(version: string) { | ||
const spec = `${PACKAGE}@${version}`; | ||
return path.resolve(__dirname, '../resources/', spec); | ||
export function getParserVersions() { | ||
return semver.rsort(fs.readdirSync(parserPath())); | ||
} | ||
|
||
export async function resolveVersion(version = 'latest') { | ||
const spec = `${PACKAGE}@${version}`; | ||
const dist = parserPath(version); | ||
await extract(spec, dist); | ||
const pkg = require(path.resolve(dist, 'package.json')); | ||
return require(path.resolve(dist, pkg.main)); | ||
export async function resolveVersion(version?: string) { | ||
if (!version) { | ||
version = getParserVersions()[0]; | ||
} | ||
const pkg = await import( | ||
`${__ASSET_PATH__}/${PACKAGE}/${version}/package.json` | ||
); | ||
return await import(`${__ASSET_PATH__}/${PACKAGE}/${version}/${pkg.main}`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
declare var __ASSET_PATH__: string; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
'use strict'; | ||
|
||
const path = require('path'); | ||
const webpack = require('webpack'); | ||
|
||
const ASSET_PATH = path.resolve(__dirname, 'resources'); | ||
|
||
/**@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'), | ||
publicPath: path.resolve(__dirname, 'resources'), | ||
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/, | ||
}, | ||
function (context, request, callback) { | ||
if (/@babel\/parser/.test(request)) { | ||
return callback(null, path.resolve(ASSET_PATH, request)); | ||
} | ||
callback(); | ||
}, | ||
], | ||
resolve: { | ||
// support reading TypeScript and JavaScript files, π -> https://github.com/TypeStrong/ts-loader | ||
extensions: ['.ts', '.js', '.json'], | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.js$/, | ||
include: /bin/, | ||
use: [ | ||
{ | ||
loader: 'shebang-loader', | ||
}, | ||
], | ||
}, | ||
{ | ||
test: /\.ts$/, | ||
exclude: /node_modules|\.vscode-test/, | ||
use: [ | ||
{ | ||
loader: 'ts-loader', | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
plugins: [ | ||
new webpack.DefinePlugin({ | ||
__ASSET_PATH__: JSON.stringify(ASSET_PATH), | ||
}), | ||
], | ||
}; | ||
module.exports = config; |
Oops, something went wrong.