fix: cjs dist should import only cjs (#120)

This commit is contained in:
Brandon Casey 2021-01-12 15:30:55 -05:00 committed by GitHub
commit a58149de54
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 3402 additions and 4029 deletions

77
.github/workflows/ci.yml vendored Normal file
View file

@ -0,0 +1,77 @@
name: ci
on: [push, pull_request]
jobs:
should-skip:
continue-on-error: true
runs-on: ubuntu-latest
# Map a step output to a job output
outputs:
should-skip-job: ${{steps.skip-check.outputs.should_skip}}
steps:
- id: skip-check
uses: fkirc/skip-duplicate-actions@v2.1.0
with:
github_token: ${{github.token}}
ci:
needs: should-skip
if: ${{needs.should-skip.outputs.should-skip-job != 'true'}}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
env:
BROWSER_STACK_USERNAME: ${{secrets.BROWSER_STACK_USERNAME}}
BROWSER_STACK_ACCESS_KEY: ${{secrets.BROWSER_STACK_ACCESS_KEY}}
runs-on: ${{matrix.os}}
steps:
- name: checkout code
uses: actions/checkout@v2
- name: Cache dependencies
uses: actions/cache@v2
with:
path: |
~/.npm
**/node_modules
key: ${{runner.os}}-npm-${{hashFiles('**/package-lock.json')}}
restore-keys: |
${{runner.os}}-npm-
${{runner.os}}-
- name: read node version from .nvmrc
run: echo ::set-output name=NVMRC::$(cat .nvmrc)
shell: bash
id: nvm
- name: update apt cache on linux w/o browserstack
run: sudo apt-get update
if: ${{startsWith(matrix.os, 'ubuntu') && !env.BROWSER_STACK_USERNAME}}
- name: install ffmpeg/pulseaudio for firefox on linux w/o browserstack
run: sudo apt-get install ffmpeg pulseaudio
if: ${{startsWith(matrix.os, 'ubuntu') && !env.BROWSER_STACK_USERNAME}}
- name: start pulseaudio for firefox on linux w/o browserstack
run: pulseaudio -D
if: ${{startsWith(matrix.os, 'ubuntu') && !env.BROWSER_STACK_USERNAME}}
- name: setup node
uses: actions/setup-node@v1
with:
node-version: '${{steps.nvm.outputs.NVMRC}}'
# turn off the default setup-node problem watchers...
- run: echo "::remove-matcher owner=eslint-compact::"
- run: echo "::remove-matcher owner=eslint-stylish::"
- run: echo "::remove-matcher owner=tsc::"
- name: npm install
run: npm i --prefer-offline --no-audit
- name: run npm test
uses: GabrielBB/xvfb-action@v1
with:
run: npm run test

2
.nvmrc
View file

@ -1 +1 @@
lts/carbon
10

View file

@ -1,16 +0,0 @@
sudo: false
dist: trusty
language: node_js
# node version is specified using the .nvmrc file
before_install:
- npm install -g greenkeeper-lockfile@1
before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- greenkeeper-lockfile-update
after_script:
- greenkeeper-lockfile-upload
addons:
firefox: latest
chrome: stable

7311
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -66,19 +66,20 @@
"test/"
],
"dependencies": {
"@babel/runtime": "^7.5.5",
"@babel/runtime": "^7.12.5",
"@videojs/vhs-utils": "^3.0.0",
"global": "^4.3.2"
"global": "^4.4.0"
},
"devDependencies": {
"rollup": "^1.19.4",
"@videojs/generator-helpers": "~1.2.0",
"karma": "^4.0.0",
"sinon": "^7.2.2",
"videojs-generate-karma-config": "~5.3.1",
"videojs-generator-verify": "~2.0.0",
"videojs-generate-rollup-config": "~5.0.1",
"videojs-standard": "^8.0.3"
"@rollup/plugin-replace": "^2.3.4",
"@videojs/generator-helpers": "~2.0.1",
"karma": "^5.2.3",
"rollup": "^2.36.1",
"sinon": "^9.2.3",
"videojs-generate-karma-config": "~7.0.0",
"videojs-generate-rollup-config": "~6.1.0",
"videojs-generator-verify": "~3.0.1",
"videojs-standard": "^8.0.4"
},
"generator-videojs-plugin": {
"version": "7.7.3"
@ -93,13 +94,7 @@
}
},
"lint-staged": {
"*.js": [
"vjsstandard --fix",
"git add"
],
"README.md": [
"doctoc --notitle",
"git add"
]
"*.js": "vjsstandard --fix",
"README.md": "doctoc --notitle"
}
}

View file

@ -1,4 +1,5 @@
const generate = require('videojs-generate-rollup-config');
const replace = require('@rollup/plugin-replace');
// see https://github.com/videojs/videojs-generate-rollup-config
// for options
@ -7,6 +8,23 @@ const options = {
externals(defaults) {
defaults.module.push('@videojs/vhs-utils');
return defaults;
},
primedPlugins(defaults) {
// when using "require" rather than import
// require cjs module
defaults.replace = replace({
// single quote replace
"require('@videojs/vhs-utils/es": "require('@videojs/vhs-utils/cjs",
// double quote replace
'require("@videojs/vhs-utils/es': 'require("@videojs/vhs-utils/cjs'
});
return defaults;
},
plugins(defaults) {
defaults.module.unshift('replace');
return defaults;
}
};