diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5050973b..eec529ca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,3 +48,29 @@ jobs: if: ${{ matrix.coverage }} with: token: ${{ secrets.CODECOV_TOKEN }} + test-legacy: + name: Test - ubuntu-latest - Node v8.9, Webpack 4 + runs-on: ubuntu-latest + env: + YARN_NODE_LINKER: node-modules + steps: + - uses: actions/checkout@v2 + - name: Use Node.js 14.x + uses: actions/setup-node@v1 + with: + node-version: 14.x + - name: Install dependencies + run: yarn + - name: Install webpack 4 + run: yarn add -D webpack@4 + - name: Build babel-loader + run: yarn run build + env: + BABEL_ENV: test + - name: Use Node.js 8.9 + uses: actions/setup-node@v1 + with: + node-version: '8.9' + - name: Run tests for webpack version 4 + run: node scripts/test-legacy + diff --git a/.gitignore b/.gitignore index ed7463b9..47579869 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ test/output !.yarn/releases .pnp.* .vscode +scripts/test-legacy-source/output diff --git a/package.json b/package.json index 55852079..456fa3c4 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ ], "main": "lib/index.js", "engines": { - "node": ">= 6.9" + "node": ">= 8.9" }, "dependencies": { "find-cache-dir": "^2.1.0", diff --git a/scripts/test-legacy-source/input.js b/scripts/test-legacy-source/input.js new file mode 100644 index 00000000..c9ff7826 --- /dev/null +++ b/scripts/test-legacy-source/input.js @@ -0,0 +1 @@ +class App {} diff --git a/scripts/test-legacy.js b/scripts/test-legacy.js new file mode 100644 index 00000000..349b4df8 --- /dev/null +++ b/scripts/test-legacy.js @@ -0,0 +1,52 @@ +const webpack = require("webpack"); +const path = require("path"); +const fs = require("fs"); +const assert = require("assert"); + +const babelLoader = path.join(__dirname, "../lib"); + +const config = { + mode: "development", + entry: path.join(__dirname, "test-legacy-source/input.js"), + output: { + path: path.join(__dirname, "test-legacy-source/output"), + }, + module: { + rules: [ + { + test: /\.jsx?/, + loader: babelLoader, + options: { + presets: ["@babel/preset-env"], + }, + exclude: /node_modules/, + }, + ], + }, +}; + +webpack(config, (err, stats) => { + assert.strictEqual(err, null); + assert.deepStrictEqual(stats.compilation.errors, []); + assert.deepStrictEqual(stats.compilation.warnings, []); + + fs.readdir(path.join(__dirname, "test-legacy-source/output"), (err, files) => { + assert.strictEqual(err, null); + assert.strictEqual(files.length, 1); + fs.readFile(path.join(__dirname, "test-legacy-source/output", files[0]), (err, data) => { + assert.strictEqual(err, null); + const test = "var App = function App()"; + const subject = data.toString(); + + assert.notStrictEqual(subject.indexOf(test), -1); + + console.log("DONE"); + clearTimeout(timeout); + }); + }); +}); + +const timeout = setTimeout(() => { + console.error("TIMEOUT"); + process.exit(1); +}, 10 * 1000);