Skip to content

Commit

Permalink
chore: bundle with rollup
Browse files Browse the repository at this point in the history
  • Loading branch information
gera2ld committed Nov 3, 2020
1 parent 919c44a commit 0933560
Show file tree
Hide file tree
Showing 20 changed files with 5,591 additions and 1,654 deletions.
8 changes: 8 additions & 0 deletions .babelrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
extends: require.resolve('@gera2ld/plaid/config/babelrc-base'),
presets: [
'@babel/preset-typescript',
],
plugins: [
].filter(Boolean),
};
1 change: 1 addition & 0 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
defaults
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# http://editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/*
!/src
!/test
12 changes: 12 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
root: true,
extends: [
require.resolve('@gera2ld/plaid-common-ts/eslint'),
],
parserOptions: {
project: './tsconfig.json',
},
rules: {
'@typescript-eslint/no-implied-eval': 'off',
},
};
19 changes: 0 additions & 19 deletions .eslintrc.json

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
out
dist
node_modules
.vscode-test/
*.vsix
13 changes: 0 additions & 13 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,6 @@
"${workspaceFolder}/out/**/*.js"
],
"preLaunchTask": "${defaultBuildTask}"
},
{
"name": "Extension Tests",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
],
"outFiles": [
"${workspaceFolder}/out/test/**/*.js"
],
"preLaunchTask": "${defaultBuildTask}"
}
]
}
6 changes: 3 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Place your settings in this file to overwrite default and user settings.
{
"files.exclude": {
"out": false // set this to true to hide the "out" folder with the compiled JS files
"dist": false // set this to true to hide the "out" folder with the compiled JS files
},
"search.exclude": {
"out": true // set this to false to include "out" folder in search results
"dist": true // set this to false to include "out" folder in search results
},
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off"
}
}
7 changes: 1 addition & 6 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@
"tasks": [
{
"type": "npm",
"script": "watch",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never"
},
"script": "build",
"group": {
"kind": "build",
"isDefault": true
Expand Down
2 changes: 2 additions & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ vsc-extension-quickstart.md
**/.eslintrc.json
**/*.map
**/*.ts
node_modules/**
**/rollup.conf.js
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Gerald

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
59 changes: 30 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{
"name": "markmap-vscode",
"displayName": "Markmap",
"description": "Visualize your markdown in VSCode",
"version": "0.0.2",
"description": "Visualize your markdown in VSCode",
"author": "Gerald <[email protected]>",
"license": "MIT",
"displayName": "Markmap",
"publisher": "gera2ld",
"icon": "assets/favicon.png",
"engines": {
Expand All @@ -19,7 +21,6 @@
"activationEvents": [
"onCustomEditor:markmap-vscode.markmap"
],
"main": "./out/extension.js",
"contributes": {
"customEditors": [
{
Expand All @@ -35,41 +36,41 @@
]
},
"scripts": {
"vscode:prepublish": "yarn run compile",
"compile": "tsc -p ./",
"lint": "eslint src --ext ts",
"watch": "tsc -watch -p ./",
"pretest": "yarn run compile && yarn run lint",
"test": "node ./out/test/runTest.js",
"transform": "locky yarn yarn"
"vscode:prepublish": "yarn lint && yarn clean && yarn build",
"build": "rollup -c rollup.conf.js",
"lint": "eslint --ext .ts,.tsx .",
"watch": "rollup -wc rollup.conf.js",
"transform": "locky yarn yarn",
"clean": "del dist types"
},
"repository": "https://github.com/gera2ld/markmap-vscode",
"main": "dist/extension.js",
"files": [
"dist",
"types"
],
"typings": "types/index.d.ts",
"dependencies": {
"@babel/runtime": "^7.12.1",
"lodash": "^4.17.20",
"markmap-lib": "^0.9.3"
},
"devDependencies": {
"@gera2ld/locky": "^0.1.0",
"@gera2ld/plaid": "~2.1.3",
"@gera2ld/plaid-common-ts": "~2.1.4",
"@gera2ld/plaid-rollup": "~2.1.3",
"@types/glob": "^7.1.3",
"@types/lodash": "^4.14.164",
"@types/mocha": "^8.0.3",
"@types/node": "^14.14.6",
"@types/vscode": "^1.50.0",
"@typescript-eslint/eslint-plugin": "^4.6.1",
"@typescript-eslint/parser": "^4.6.1",
"eslint": "^7.12.1",
"glob": "^7.1.6",
"husky": "^4.3.0",
"mocha": "^8.2.1",
"typescript": "^4.0.5",
"vscode-test": "^1.4.1"
},
"dependencies": {
"lodash": "^4.17.20",
"markmap-lib": "^0.9.3"
"del-cli": "^3.0.1",
"husky": "^4.3.0"
},
"husky": {
"hooks": {
"pre-commit": "yarn transform -t",
"pre-push": "yarn lint"
"pre-push": "yarn lint",
"pre-commit": "yarn transform -t"
}
},
"repository": "https://github.com/gera2ld/markmap-vscode",
"author": "Gerald <[email protected]>",
"license": "MIT"
}
}
59 changes: 59 additions & 0 deletions rollup.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
const {
defaultOptions,
getRollupExternal,
getRollupPlugins,
loadConfigSync,
rollupMinify,
} = require('@gera2ld/plaid');
const pkg = require('./package.json');

const DIST = defaultOptions.distDir;
const FILENAME = 'extension';
const BANNER = `/*! ${pkg.name} v${pkg.version} | ${pkg.license} License */`;

const external = [
'path',
'vscode',
];
const bundleOptions = {
extend: true,
esModule: false,
};
const postcssConfig = loadConfigSync('postcss') || require('@gera2ld/plaid/config/postcssrc');
const postcssOptions = {
...postcssConfig,
inject: false,
};
const rollupConfig = [
{
input: {
input: 'src/extension.ts',
plugins: getRollupPlugins({
extensions: defaultOptions.extensions,
postcss: postcssOptions,
}),
external,
},
output: {
format: 'cjs',
file: `${DIST}/${FILENAME}.js`,
},
},
];

rollupConfig.forEach((item) => {
item.output = {
indent: false,
// If set to false, circular dependencies and live bindings for external imports won't work
externalLiveBindings: false,
...item.output,
...BANNER && {
banner: BANNER,
},
};
});

module.exports = rollupConfig.map(({ input, output }) => ({
...input,
output,
}));
Loading

0 comments on commit 0933560

Please sign in to comment.