Skip to content

Commit

Permalink
Merge cf76318 into 44c80ba
Browse files Browse the repository at this point in the history
  • Loading branch information
ogonkov committed Oct 30, 2020
2 parents 44c80ba + cf76318 commit aaf1ca5
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
matrix:
os: [windows-latest, ubuntu-latest]
node-version: [8.9.x, 12.x]
node-version: [10.13.x, 12.x]

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

This Webpack loader compiles [Fest](https://github.com/mailru/fest) templates.

> For Webpack 4.x use loader versions 2.x
Loader is trying to build dependencies tree by walking through
`<fest:include/>`, `<fest:insert/>` and `<fest:script/>` tags of template.

Expand Down
4 changes: 3 additions & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const nodeVersion = require('./package.json').engines.node;

module.exports = function(api) {
api.cache(true);

Expand All @@ -7,7 +9,7 @@ module.exports = function(api) {
'@babel/preset-env',
{
targets: {
node: '8.9.0'
node: nodeVersion.replace(/>=\s+/, '')
}
}
]
Expand Down
21 changes: 9 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,26 @@
"version": "2.3.0",
"description": "Webpack loader for fest",
"main": "es/loader.js",
"dependencies": {
"loader-utils": "^2.0.0",
"schema-utils": "^2.0.0"
},
"dependencies": {},
"devDependencies": {
"@babel/cli": "^7.11.5",
"@babel/core": "^7.11.5",
"@babel/preset-env": "^7.11.5",
"babel-jest": "^26.3.0",
"@babel/cli": "^7.12.1",
"@babel/core": "^7.12.3",
"@babel/preset-env": "^7.12.1",
"babel-jest": "^26.6.1",
"coveralls": "^3.0.9",
"eslint": "^6.8.0",
"eslint": "^7.12.1",
"fest": "^0.12.1",
"jest": "^25.5.4",
"jest": "^26.6.1",
"memory-fs": "^0.5.0",
"webpack": "^4.44.1",
"webpack": "^5.0.0",
"xml2js": "^0.4.23"
},
"peerDependencies": {
"fest": "^0.12.1",
"xml2js": "^0.4.23"
},
"engines": {
"node": ">= 8.9.0"
"node": ">= 10.13.0"
},
"scripts": {
"lint": "eslint src",
Expand Down
9 changes: 2 additions & 7 deletions src/loader.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import {getOptions} from 'loader-utils';
import validateOptions from 'schema-utils';
import fest from 'fest';

import {getDependencies} from './get-dependencies';

const schema = {
title: 'Fest Loader options',
type: 'object',
properties: {
beautify: {
Expand Down Expand Up @@ -64,11 +63,7 @@ export default function festLoader(source) {

let options;
try {
options = getOptions(this);
validateOptions(schema, options, {
name: 'Fest Loader',
baseDataPath: 'options'
});
options = this.getOptions(schema);
} catch (e) {
callback(e);

Expand Down
1 change: 1 addition & 0 deletions test/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import memoryfs from 'memory-fs';

export default (fixture, options = {}) => {
const compiler = webpack({
mode: 'production',
context: __dirname,
entry: `./${fixture}`,
output: {
Expand Down
7 changes: 2 additions & 5 deletions test/get-loader-context.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
export function getLoaderContext(resourcePath, options = {}) {
const callback = jest.fn().mockName('loaderContext.callback');
const query = Object.entries(options).map(([key, value]) => {
return `${key}=${value}`;
}, '').join('&');
const context = {
query: `?${query}`,
resourcePath,
async: jest.fn().mockReturnValue(callback),
addDependency: jest.fn().mockName('loaderContext.addDependency'),
emitWarning: jest.fn().mockName('loaderContext.emitWarning')
emitWarning: jest.fn().mockName('loaderContext.emitWarning'),
getOptions: jest.fn().mockName('loaderContext.getOptions').mockReturnValue(options)
};
const result = new Promise(function(resolve, reject) {
callback.mockImplementation(function(error, result) {
Expand Down
4 changes: 3 additions & 1 deletion test/get-output.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export function getOutput(stats) {
return stats.toJson().modules[0].source;
return stats.toJson({
source: true
}).modules[0].source;
}
8 changes: 6 additions & 2 deletions test/loader.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ describe('dependencies parse', function() {
});

expect(stats.toJson().warnings).toEqual(expect.arrayContaining([
expect.stringMatching('Invalid character in entity name')
expect.objectContaining({
details: expect.stringMatching('Invalid character in entity name')
})
]));
});

Expand All @@ -88,7 +90,9 @@ describe('dependencies parse', function() {
});

expect(stats.toJson().warnings).toEqual(expect.arrayContaining([
expect.stringMatching(/fixtures[\/\\]invalid\.xml/)
expect.objectContaining({
details: expect.stringMatching(/fixtures[\/\\]invalid\.xml/)
})
]));
});

Expand Down

0 comments on commit aaf1ca5

Please sign in to comment.