-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Address feedback, and adds more tests
- Loading branch information
Showing
14 changed files
with
109 additions
and
68 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,41 +1,64 @@ | ||
name: CI | ||
on: pull_request | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
- release-* | ||
pull_request: | ||
branches: | ||
- master | ||
- release-* | ||
|
||
jobs: | ||
test: | ||
ci: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [10.x, 12.x, 14.x] | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: "14.x" | ||
- name: Setup Testing Infra | ||
run: | | ||
cd test | ||
npm install | ||
- name: "CommonJS Test" | ||
run: | | ||
cd test/cjs | ||
npm run test | ||
- name: "ES Modules Test" | ||
run: | | ||
cd test/esm-node-native | ||
npm run test | ||
- name: "Rollup Tree-shaking Test" | ||
run: | | ||
cd test/rollup-modules | ||
npm run test | ||
- name: "Webpack Tree-shaking Test" | ||
run: | | ||
cd test/webpack-modules | ||
npm run test | ||
- name: "Snowpack Tree-shaking Test" | ||
run: | | ||
cd test/snowpack-modules | ||
npm run test | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Use node version ${{ matrix.node-version }} | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
|
||
- name: Setup Testing Infra | ||
run: | | ||
cd test | ||
npm install | ||
- name: "CommonJS Test" | ||
run: | | ||
cd test/cjs | ||
npm run test | ||
- name: "ES Modules Test" | ||
run: | | ||
cd test/esm-node-native | ||
npm run test | ||
if: ${{ matrix.node-version == "14.x" }} | ||
|
||
- name: "Validate ES Modules == CommonJS" | ||
run: | | ||
cd test/validateModuleExportsMatchCommonJS | ||
npm run test | ||
if: ${{ matrix.node-version == "14.x" }} | ||
|
||
- name: "Rollup Tree-shaking Test" | ||
run: | | ||
cd test/rollup-modules | ||
npm run test | ||
- name: "Webpack Tree-shaking Test" | ||
run: | | ||
cd test/webpack-modules | ||
npm run test | ||
- name: "Snowpack Tree-shaking Test" | ||
run: | | ||
cd test/snowpack-modules | ||
npm run test |
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 |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
bower.json | ||
docs | ||
test | ||
.npmrc |
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 @@ | ||
package-lock=false |
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,4 +1,2 @@ | ||
package-lock.json | ||
rollup-modules/output | ||
webpack-modules/dist | ||
snowpack-modules/build | ||
*/build |
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,7 +1,2 @@ | ||
const { __awaiter } = require("tslib"); | ||
|
||
const testFunction = (textToPrint) => __awaiter(void 0, void 0, void 0, function* () { | ||
console.log(`State: ${textToPrint}`); | ||
}); | ||
|
||
testFunction("Works") | ||
const tslib = require("tslib"); | ||
if (typeof tslib.__awaiter !== "function") throw new Error("Missing expected helper __awaiter"); |
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,7 +1,2 @@ | ||
import { __awaiter } from "tslib"; | ||
|
||
export const testFunction = (textToPrint) => __awaiter(void 0, void 0, void 0, function* () { | ||
console.log(`State: ${textToPrint}`); | ||
}); | ||
|
||
testFunction("Works") | ||
if (typeof __awaiter !== "function") throw new Error("Missing expected helper __awaiter"); |
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,7 +1,2 @@ | ||
import { __awaiter } from "tslib"; | ||
|
||
export const testFunction = (textToPrint) => __awaiter(void 0, void 0, void 0, function* () { | ||
console.log(`State: ${textToPrint}`); | ||
}); | ||
|
||
testFunction("Works") | ||
if (typeof __awaiter !== "function") throw new Error("Missing expected helper __awaiter"); |
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,5 @@ | ||
{ | ||
"scripts": { | ||
"test": "../node_modules/.bin/rollup -c rollup.config.js && node output/index.js" | ||
"test": "../node_modules/.bin/rollup -c rollup.config.js && node build/index.js" | ||
} | ||
} |
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,7 +1,2 @@ | ||
import { __awaiter } from "tslib"; | ||
|
||
export const testFunction = (textToPrint) => __awaiter(void 0, void 0, void 0, function* () { | ||
console.log(`State: ${textToPrint}`); | ||
}); | ||
|
||
testFunction("Works") | ||
if (typeof __awaiter !== "function") throw new Error("Missing expected helper __awaiter"); |
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,23 @@ | ||
// When on node 14, it validates that all of the commonjs exports | ||
// are correctly re-exported for es modules importers. | ||
|
||
const nodeMajor = Number(process.version.split(".")[0].slice(1)) | ||
if (nodeMajor < 14) { | ||
console.log("Skipping because node does not support module exports.") | ||
process.exit(0) | ||
} | ||
|
||
// ES Modules import via the ./modules folder | ||
import * as esTSLib from "../../modules/index.js" | ||
|
||
// Force a commonjs resolve | ||
import { createRequire } from "module"; | ||
const commonJSTSLib = createRequire(import.meta.url)("../../tslib.js"); | ||
|
||
for (const key in commonJSTSLib) { | ||
if (commonJSTSLib.hasOwnProperty(key)) { | ||
if(!esTSLib[key]) throw new Error(`ESModules is missing ${key} - it needs to be re-exported in ./modules/index.js`) | ||
} | ||
} | ||
|
||
console.log("All exports in commonjs are available for es module consumers.") |
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,6 @@ | ||
{ | ||
"type": "module", | ||
"scripts": { | ||
"test": "node index.js" | ||
} | ||
} |
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,5 @@ | ||
{ | ||
"scripts": { | ||
"test": "../node_modules/.bin/webpack && node dist/main.js" | ||
"test": "../node_modules/.bin/webpack && node build/main.js" | ||
} | ||
} |
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,4 +1,13 @@ | ||
module.exports = { | ||
const path = require('path'); | ||
|
||
/** @type {import("webpack").Configuration} */ | ||
const config = { | ||
mode: "production", | ||
entry: "./index" | ||
entry: "./index", | ||
output: { | ||
path: path.join(process.cwd(), 'build') | ||
} | ||
|
||
} | ||
|
||
module.exports = config |