Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump dependencies #23

Merged
merged 44 commits into from
Feb 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
5a4a79b
Add update script
compulim Feb 27, 2022
8804ac9
Add tests
compulim Feb 27, 2022
f0222ec
Fix syntax error
compulim Feb 27, 2022
7499fdc
Fix syntax error
compulim Feb 27, 2022
501dfcd
Upload all tests
compulim Feb 27, 2022
db0e000
Add trigger
compulim Feb 27, 2022
a80d079
Update name
compulim Feb 27, 2022
77832d1
Update build script
compulim Feb 27, 2022
386cfd3
Update artifact name
compulim Feb 27, 2022
42d84a2
Update folder
compulim Feb 27, 2022
bb72b4f
Update tarball filename
compulim Feb 27, 2022
cfe5a59
Merge Dockerfile
compulim Feb 27, 2022
9001e53
Add LTS/latest and debug
compulim Feb 27, 2022
2732604
Reduce versions
compulim Feb 27, 2022
9fadb51
Separate tests
compulim Feb 27, 2022
bb72108
Fix build script
compulim Feb 27, 2022
34e2556
Fix syntax error
compulim Feb 27, 2022
dfb5859
Fix build script
compulim Feb 27, 2022
6e68f80
Separate RUN commands
compulim Feb 27, 2022
03b86e3
Remove unneeded files
compulim Feb 27, 2022
949e0cb
Update deps
compulim Feb 27, 2022
e5c0b86
Update read-pkg-up
compulim Feb 27, 2022
d72bc35
Fix test
compulim Feb 27, 2022
03406a9
Fix expected.txt
compulim Feb 27, 2022
3acc22f
Change directory before test
compulim Feb 27, 2022
c0ba5b2
Add more tests
compulim Feb 27, 2022
1787a96
Add esbuild
compulim Feb 27, 2022
787ad8f
Update expected
compulim Feb 27, 2022
3ecec05
Add npm-version
compulim Feb 27, 2022
47c3f0a
Fix build-arg
compulim Feb 27, 2022
cf3688d
Rename matrix
compulim Feb 27, 2022
a5d140e
Add webpack-esm
compulim Feb 27, 2022
10f8087
Add rollup
compulim Feb 28, 2022
ab15f51
Add 12.x
compulim Feb 28, 2022
d2f99d6
Reduce test files
compulim Feb 28, 2022
7345658
Clean up
compulim Feb 28, 2022
063a8d3
Move terser to devDependencies
compulim Feb 28, 2022
74b22b6
Better task names
compulim Feb 28, 2022
3f39fab
Update version of @babel/runtime
compulim Feb 28, 2022
16652fe
Add global test
compulim Feb 28, 2022
e523399
Only upload once
compulim Feb 28, 2022
c2500ae
Add PR template
compulim Feb 28, 2022
d1fb981
Add entry
compulim Feb 28, 2022
5542cbd
Add summary section
compulim Feb 28, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## Summary

<!-- Explain the purpose of this pull request in one line. -->

## Changelog

### Fixed/Added/Changed

<!-- Copy and paste the entry from CHANGELOG.md. -->

## Design considerations

<!-- Explains how we come up with the final design and design candidates (if any). -->

## Specific changes

<!-- Explains what changed in details. -->

-

## Reminders

<!-- Checks all boxes even if it is irrelevant to this pull request. -->

- [ ] I have updated `CHANGELOG.md`
- [ ] I have added tests for new code
- [ ] I have updated documentations
96 changes: 96 additions & 0 deletions .github/workflows/docker-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Pull request validation

on:
pull_request:

workflow_dispatch:
inputs:
version:
description: 'Version'
required: true
default: 'master'

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: ['12', '14', '16']
npm-version: [default, latest]

steps:
- name: Checking out for ${{ github.ref }}
uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

- name: Install latest NPM
if: ${{ matrix.npm-version == 'latest' }}
run: npm install -g npm

- run: |
npm install
npm run prepublishOnly
npm pack

- name: Upload end-to-end tests
uses: actions/upload-artifact@v2
if: ${{ matrix.node-version == '16' && matrix.npm-version == 'default' }}
with:
name: e2e-tests
path: '__e2e__/**/*'

- name: Upload package tarball
uses: actions/upload-artifact@v2
if: ${{ matrix.node-version == '16' && matrix.npm-version == 'default' }}
with:
name: package
path: '*.tgz'

test:
needs: build
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
resolver:
- esbuild
- node-commonjs
- node-esm
- node-global
- rollup
- webpack4-commonjs
- webpack4-esm
- webpack5-commonjs
- webpack5-esm
node-version: ['12', '14', '16']
npm-version: [default, latest]

steps:
- name: Download end-to-end tests
uses: actions/download-artifact@v2
with:
name: e2e-tests

- name: Download package tarball
uses: actions/download-artifact@v2
with:
name: package

- name: Build test image
run: |
cd ${{ matrix.resolver }}
cp ../*.tgz .
ls -la
docker build --build-arg NODE_VERSION=${{ matrix.node-version }} --build-arg NPM_VERSION=${{ matrix.npm-version }} --file Dockerfile --tag test-image .

- name: Run test
run: |
cd ${{ matrix.resolver }}
docker run --name test-container test-image > actual.txt
diff expected.txt actual.txt
98 changes: 0 additions & 98 deletions .github/workflows/e2e-test.yml

This file was deleted.

15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Updated end-to-end tests, by [@compulim](https://github.com/compulim), in PR [#23](https://github.com/compulim/p-defer-es5/pull/23)
- Using Docker to isolate tests
- Test against different combinations of Node.js, NPM, and resolvers
- Bumped dependencies, by [@compulim](https://github.com/compulim), in PR [#23](https://github.com/compulim/p-defer-es5/pull/23)
- [`@babel/cli@7.17.6`](https://npmjs.com/package/@babel/cli)
- [`@babel/core@7.17.5`](https://npmjs.com/package/@babel/core)
- [`@babel/plugin-transform-runtime@7.17.0`](https://npmjs.com/package/@babel/plugin-transform-runtime)
- [`@babel/preset-env@7.16.11`](https://npmjs.com/package/@babel/preset-env)
- [`@babel/runtime-corejs3@7.17.2`](https://npmjs.com/package/@babel/runtime-corejs3)
- [`esbuild@0.14.23`](https://npmjs.com/package/esbuild)
- [`read-pkg-up@9.1.0`](https://npmjs.com/package/read-pkg-up)
- [`terser@5.11.0`](https://npmjs.com/package/terser)

## [2.0.0] - 2021-07-20

### Added
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

This package is based on [`p-defer`](https://npmjs.com/package/p-defer). It did not contains an ES5 module. Importing the module directly or indirectly may break web apps running on ES5 browsers.

On install, this package will transpile your version of `p-defer` to make it compatible with ES5 browsers.
On `npm install`, this package will transpile your version of `p-defer` to make it compatible with ES5 browsers. Then in your code, you use `p-defer-es5` instead of `p-defer`.

Package authors should consider importing this package instead of `p-defer`, so your packages will not break your users due to having `p-defer` as a transient dependency.

Expand All @@ -24,7 +24,7 @@ You can also use it in HTML:

## How it works

On `postinstall`, this package will run Babel and Webpack to transpile `p-defer` into a single file.
On `postinstall`, this package will run `esbuild` to bundle `p-defer` into a single file. Then run Babel to transpile it for ES5.

This package peer-depends on `p-defer`. Thus, you can select your own version of `p-defer`.

Expand All @@ -44,7 +44,7 @@ Be sure to include the original license and continue to depends on the package t

### Modify your bundler configuration

Webpack do not transpile code under `/node_modules/` unless specified explicitly. You can modify `webpack.config.js` to include `/node_modules/p-defer/` and use `babel-loader` to transpile it on-the-fly.
Some bundlers is configured not to transpile code under `/node_modules/` unless specified explicitly. You can modify bundler configuration to include `/node_modules/p-defer/` and use Babel to transpile it while bundling.

## Contributions

Expand Down
1 change: 1 addition & 0 deletions __e2e__/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/**/p-defer-es5-*.tgz
21 changes: 21 additions & 0 deletions __e2e__/esbuild/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
ARG NODE_VERSION=16

FROM node:$NODE_VERSION-alpine
ARG NPM_VERSION

WORKDIR /var/test/
COPY * /var/test/

RUN if [[ "$NPM_VERSION" == "latest" ]] ; then npm install -g npm ; fi

RUN node --version
RUN npm --version

RUN npm init --yes
RUN npm install p-defer
RUN npm install ./`ls *.tgz`

# The lowest version supported by ESBuild is "es2016".
RUN npx esbuild ./index.js --bundle --minify --outfile=./dist/main.js --target=es2016

ENTRYPOINT node ./dist/main.js
1 change: 1 addition & 0 deletions __e2e__/esbuild/expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello, World!
17 changes: 17 additions & 0 deletions __e2e__/esbuild/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// When bundling with esbuild:
// - If we "import", it load ESM from "p-defer-es5/module". The default imported object is () => any.
// - If we "require", it load CJS from "p-defer-es5/main". The default imported object is () => any.

// When bundling with Webpack:
// - Nomatter we "import" or "require", it always load ESM from "p-defer-es5/module", based on the "webpack.config.json/mainFields".
// - If we "import", the default imported object is () => any.
// - If we "require", the default imported object is { default: () => any }.
// - If we "require" and "mainFields" is "main", the default imported object is () => any.

const createDeferred = require('p-defer-es5');

const { promise, resolve } = createDeferred();

setTimeout(() => resolve('Hello, World!'), 0);

promise.then(result => console.log(result));
18 changes: 18 additions & 0 deletions __e2e__/node-commonjs/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
ARG NODE_VERSION=16

FROM node:$NODE_VERSION-alpine
ARG NPM_VERSION

WORKDIR /var/test/
COPY * /var/test/

RUN if [[ "$NPM_VERSION" == "latest" ]] ; then npm install -g npm ; fi

RUN node --version
RUN npm --version

RUN npm init --yes
RUN npm install p-defer
RUN npm install ./`ls *.tgz`

ENTRYPOINT node ./index.js
1 change: 1 addition & 0 deletions __e2e__/node-commonjs/expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello, World!
7 changes: 7 additions & 0 deletions __e2e__/node-commonjs/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const createDeferred = require('p-defer-es5');

const { promise, resolve } = createDeferred();

setTimeout(() => resolve('Hello, World!'), 0);

promise.then(console.log.bind(console));
18 changes: 18 additions & 0 deletions __e2e__/node-esm/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
ARG NODE_VERSION=16

FROM node:$NODE_VERSION-alpine
ARG NPM_VERSION

WORKDIR /var/test/
COPY * /var/test/

RUN if [[ "$NPM_VERSION" == "latest" ]] ; then npm install -g npm ; fi

RUN node --version
RUN npm --version

RUN npm init --yes
RUN npm install p-defer
RUN npm install ./`ls *.tgz`

ENTRYPOINT node ./index.mjs
1 change: 1 addition & 0 deletions __e2e__/node-esm/expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello, World!
7 changes: 7 additions & 0 deletions __e2e__/node-esm/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import createDeferred from 'p-defer-es5';

const { promise, resolve } = createDeferred();

setTimeout(() => resolve('Hello, World!'), 0);

promise.then(console.log.bind(console));
18 changes: 18 additions & 0 deletions __e2e__/node-global/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
ARG NODE_VERSION=16

FROM node:$NODE_VERSION-alpine
ARG NPM_VERSION

WORKDIR /var/test/
COPY * /var/test/

RUN if [[ "$NPM_VERSION" == "latest" ]] ; then npm install -g npm ; fi

RUN node --version
RUN npm --version

RUN npm init --yes
RUN npm install p-defer
RUN npm install ./`ls *.tgz`

ENTRYPOINT node ./index.js
1 change: 1 addition & 0 deletions __e2e__/node-global/expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello, World!
Loading