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

Update dependency webpack to v5 #66

Merged
merged 3 commits into from
Oct 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ jobs:
node-version: ${{ matrix.node-version }}
- run: npm install --global yarn@1
- run: yarn install
- run: yarn test
- run: npm test
5 changes: 4 additions & 1 deletion example/example.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ const config = require('./webpack.config');
test('extracts frontmatter and body as an object', () =>
new Promise((resolve) => {
webpack(config, (error, stats) => {
if (error) {
throw error;
}
const bundlePath = path.resolve(
stats.compilation.compiler.outputPath,
stats.toJson().assetsByChunkName.main
stats.toJson().assetsByChunkName.main[0]
);
expect(require(bundlePath)).toMatchInlineSnapshot(`
Object {
Expand Down
2 changes: 1 addition & 1 deletion example/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = {
rules: [
{
test: /\.md$/,
loaders: ['json-loader', frontMatterLoader],
use: ['json-loader', frontMatterLoader],
},
],
},
Expand Down
3 changes: 1 addition & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
'use strict';

var loaderUtils = require('loader-utils');
var fm = require('front-matter');

module.exports = function (source) {
this.cacheable && this.cacheable();
var options = loaderUtils.getOptions(this) || {};
var options = this.getOptions() || {};

var frontmatter = fm(source);
if (options.onlyAttributes) {
Expand Down
6 changes: 3 additions & 3 deletions index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Here is some example content`;
test('extracts frontmatter and body as an object', () => {
const context = {
cacheable: jest.fn(),
query: '',
getOptions: () => ({}),
};

expect(frontMatterLoader.call(context, source)).toBe(
Expand All @@ -29,7 +29,7 @@ test('extracts frontmatter and body as an object', () => {
test('extracts only the frontmatter when onlyAttributes is passed', () => {
const context = {
cacheable: jest.fn(),
query: '?onlyAttributes',
getOptions: () => ({ onlyAttributes: true }),
};

expect(frontMatterLoader.call(context, source)).toBe(
Expand All @@ -40,7 +40,7 @@ test('extracts only the frontmatter when onlyAttributes is passed', () => {
test('extracts only the body when onlyBody is passed', () => {
const context = {
cacheable: jest.fn(),
query: '?onlyBody',
getOptions: () => ({ onlyBody: true }),
};

expect(frontMatterLoader.call(context, source)).toBe(
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@
},
"homepage": "https://github.com/elliottsj/front-matter-loader#readme",
"dependencies": {
"front-matter": "^4.0.0",
"loader-utils": "^2.0.0"
"front-matter": "^4.0.0"
},
"devDependencies": {
"jest": "26.5.3",
"json-loader": "0.5.7",
"prettier": "2.1.2",
"webpack": "4.44.1"
"webpack": "5.1.3"
},
"jest": {
"testEnvironment": "node"
Expand Down
Loading