-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
9,107 additions
and
152 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,13 @@ | ||
|
||
{ | ||
"presets": ["es2015"], | ||
"plugins": [] | ||
"presets": [ | ||
[ | ||
"@babel/preset-env", | ||
{ | ||
"targets": { | ||
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"] | ||
} | ||
} | ||
] | ||
], | ||
"plugins": ["@babel/plugin-transform-runtime"] | ||
} |
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,2 @@ | ||
.yarn/releases/** binary | ||
.yarn/plugins/** binary |
Validating CODEOWNERS rules …
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,2 @@ | ||
# Global Rule: | ||
* @sbolel |
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,28 @@ | ||
## Summary | ||
|
||
<!-- Overview of changes --> | ||
|
||
### Added | ||
|
||
<!-- List new features or components. Include a screenshot for new visual elements. --> | ||
|
||
### Changed | ||
|
||
<!-- List changes in existing functionality or design. | ||
If the change was visual, include a comparison screenshot showing the before and after the visual change. --> | ||
|
||
### Deprecated | ||
|
||
<!-- List once-stable features or components to be deprecated in this PR. --> | ||
|
||
### Removed | ||
|
||
<!-- List deprecated features or components removed in this PR. --> | ||
|
||
### Fixed | ||
|
||
<!-- List any bug fixes. --> | ||
|
||
## How to test | ||
|
||
<!-- Instructions on how to test the changes. This is not an exhaustive list of ways you should test this PR. --> |
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,16 @@ | ||
version: 2 | ||
|
||
updates: | ||
- package-ecosystem: 'npm' | ||
directory: '/' | ||
schedule: | ||
interval: 'weekly' | ||
day: 'friday' | ||
time: '08:00' | ||
timezone: 'America/New_York' | ||
labels: | ||
- 'dependencies' | ||
rebase-strategy: 'auto' | ||
reviewers: | ||
- 'sbolel' | ||
versioning-strategy: increase |
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,63 @@ | ||
name: CI/CD | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
types: | ||
- opened | ||
- reopened | ||
- synchronize | ||
|
||
jobs: | ||
test_build_release: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: [19] | ||
env: | ||
CI: true | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Node.js and yarn | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: 'yarn' | ||
cache-dependency-path: 'yarn.lock' | ||
|
||
- name: Get yarn cache directory path | ||
id: yarn-cache-path | ||
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT | ||
|
||
- name: Cache yarn packages | ||
id: yarn-cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: ${{ steps.yarn-cache-path.outputs.dir }} | ||
key: node-${{ matrix.node-version }}-yarn-${{ hashFiles('**/yarn.lock', '.yarnrc.yml') }} | ||
restore-keys: | | ||
node-${{ matrix.node-version }}-yarn- | ||
- name: Install dependencies | ||
run: yarn install --immutable | ||
|
||
- name: Lint | ||
run: yarn lint | ||
|
||
- name: Test | ||
run: yarn test | ||
|
||
- name: Build | ||
run: yarn build | ||
|
||
# semantic-release will only run on pushes to main (see package.json) | ||
# - name: Release | ||
# run: yarn semantic-release | ||
# env: | ||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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 |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
.git | ||
.gitignore | ||
.npmignore | ||
.yarn | ||
circle.yml | ||
node_modules | ||
npm-debug.log | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
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,9 @@ | ||
enableTelemetry: false | ||
|
||
nodeLinker: node-modules | ||
|
||
plugins: | ||
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs | ||
spec: "@yarnpkg/plugin-interactive-tools" | ||
|
||
yarnPath: .yarn/releases/yarn-3.6.0.cjs |
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
File renamed without changes.
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,121 @@ | ||
/** | ||
* Create Webpack Configuration | ||
* @param {Object} options | ||
* @param {boolean} options.dev | ||
* @param {string} options.target | ||
* @returns {Object} | ||
*/ | ||
const path = require('path') | ||
const webpack = require('webpack') | ||
const TerserPlugin = require('terser-webpack-plugin') | ||
const pkg = require('../package.json') | ||
|
||
// paths | ||
const buildPath = 'dist' | ||
const publicPath = 'assets' | ||
|
||
/** | ||
* Create Webpack Configuration | ||
* @param {Object} options - options object | ||
* @param {boolean} options.dev - development mode | ||
* @param {string} options.target - target | ||
* @returns {Object} | ||
* @example | ||
* const webpack = require('webpack') | ||
* const createWebpackConfig = require('./create-webpack-config') | ||
* const webpackConfig = createWebpackConfig({ dev: true, target: 'web' }) | ||
* webpack(webpackConfig, (err, stats) => { | ||
* if (err || stats.hasErrors()) { | ||
* // Handle errors here | ||
* } | ||
* // Done processing | ||
* }) | ||
*/ | ||
const createWebpackConfig = (options = {}) => { | ||
/** | ||
* Get chunk name with the correct extension | ||
* @param {Object} chunkData - chunk data | ||
* @param {Object} chunkData.chunk - chunk object | ||
* @param {string} chunkData.chunk.name - chunk name | ||
* @returns {string} chunk name | ||
*/ | ||
const getChunkName = ({ chunk: { name = '' } } = {}) => { | ||
if (!name) throw new Error('Chunk name is required') | ||
const ext = options.dev ? '.js' : '.min.js' | ||
return name === 'main' ? `pano${ext}` : `pano-[name]${ext}` | ||
} | ||
|
||
return { | ||
target: options.target, | ||
devtool: options.dev ? 'eval-source-map' : 'source-map', | ||
mode: options.dev ? 'development' : 'production', | ||
module: { | ||
rules: [ | ||
{ | ||
exclude: /node_modules/, | ||
use: ['babel-loader'], | ||
test: /\.js$/, | ||
}, | ||
], | ||
}, | ||
output: { | ||
filename: getChunkName, | ||
library: { | ||
name: 'Pano', | ||
type: 'umd', | ||
}, | ||
path: path.resolve(__dirname, '..', buildPath), | ||
publicPath: `/${buildPath}/`, | ||
}, | ||
plugins: [ | ||
new webpack.BannerPlugin({ | ||
banner: `pano.js v${pkg.version} | (c) Sinan Bolel & Prescott Prue`, | ||
entryOnly: true, | ||
raw: false, | ||
}), | ||
new webpack.EnvironmentPlugin({ | ||
npm_lifecycle_event: '', // override to avoid error | ||
}) | ||
], | ||
resolve: { | ||
alias: { | ||
assets: path.resolve(__dirname, '..', publicPath), | ||
}, | ||
extensions: ['.js'], | ||
}, | ||
optimization: { | ||
minimize: !options.dev, | ||
minimizer: [ | ||
new TerserPlugin({ | ||
terserOptions: { | ||
compress: { | ||
warnings: false, | ||
drop_console: true, | ||
drop_debugger: true, | ||
}, | ||
output: { | ||
comments: false, | ||
}, | ||
}, | ||
}), | ||
], | ||
splitChunks: { | ||
cacheGroups: { | ||
defaultVendors: { | ||
name: 'vendor', | ||
test: /[\\/]node_modules[\\/]/, | ||
priority: -10, | ||
chunks: 'all', | ||
}, | ||
default: { | ||
test: /[\\/]src[\\/]/, | ||
name: 'pano', | ||
priority: -20, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
module.exports = createWebpackConfig |
Oops, something went wrong.