Skip to content

Commit

Permalink
chore(release): 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi authored Jun 24, 2020
1 parent e0bc930 commit 7829c1b
Show file tree
Hide file tree
Showing 7 changed files with 1,418 additions and 1,153 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [1.1.0](https://github.com/webpack-contrib/exports-loader/compare/v1.0.1...v1.1.0) (2020-06-24)


### Features

* "|" character can be used as delimiter for inline string syntax ([#46](https://github.com/webpack-contrib/exports-loader/issues/46)) ([e0bc930](https://github.com/webpack-contrib/exports-loader/commit/e0bc930d84d83107f3d7bf1c761f9af8bca26931))

## [1.0.1](https://github.com/webpack-contrib/exports-loader/compare/v1.0.0...v1.0.1) (2020-06-17)


Expand Down
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ For further hints on compatibility issues, check out [Shimming](https://webpack.

> ⚠ By default loader generate ES module named syntax.
>
> ⚠ Be careful, existing exports (`export`/`module.exports`/`exports`) in the original code and exporting new values can cause failure.
> ⚠ Be careful, existing exports (`export`/`module.exports`/`exports`) in the original code and exporting new values can cause a failure.
## Getting Started

Expand All @@ -34,11 +34,7 @@ $ npm install exports-loader --save-dev

### Inline

The `|` or `%20` (space) separate command parts.

> `%20` is space in a query string, because you can't use spaces in URLs
Then add the loader to the desired `require` calls. For example:
Then add the loader to the desired `import` statemtnt and `require` calls. For example:

```js
import { myFunction } from 'exports-loader?exports=myFunction!./file.js';
Expand Down Expand Up @@ -85,8 +81,14 @@ const {
myFunction('Hello world');
```

The `|` or `%20` (space) allow to separate the [`syntax`](#syntax), [`name`](#name) and [`alias`](#alias) of export.

> `%20` is space in a query string, because you can't use spaces in URLs
```js
import myFunction from 'exports-loader?exports=default%20myFunction!./file.js';
// Alternative syntax:
// import myFunction from 'exports-loader?exports=default%20myFunction!./file.js';
import myFunction from 'exports-loader?exports=default|myFunction!./file.js';
// `%20` is space in a query string, equivalently `default myFunction`
// Adds the following code to the file's source:
//
Expand Down
2,260 changes: 1,126 additions & 1,134 deletions package-lock.json

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "exports-loader",
"version": "1.0.1",
"version": "1.1.0",
"description": "exports loader module for webpack",
"license": "MIT",
"repository": "webpack-contrib/exports-loader",
Expand Down Expand Up @@ -46,24 +46,24 @@
"source-map": "^0.6.1"
},
"devDependencies": {
"@babel/cli": "^7.10.1",
"@babel/core": "^7.10.2",
"@babel/preset-env": "^7.10.2",
"@commitlint/cli": "^8.3.5",
"@commitlint/config-conventional": "^8.3.4",
"@babel/cli": "^7.10.3",
"@babel/core": "^7.10.3",
"@babel/preset-env": "^7.10.3",
"@commitlint/cli": "^9.0.1",
"@commitlint/config-conventional": "^9.0.1",
"@webpack-contrib/defaults": "^6.3.0",
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
"babel-jest": "^26.0.1",
"babel-jest": "^26.1.0",
"babel-loader": "^8.1.0",
"cross-env": "^7.0.2",
"del": "^5.1.0",
"del-cli": "^3.0.1",
"eslint": "^7.2.0",
"eslint": "^7.3.1",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-import": "^2.21.2",
"husky": "^4.2.5",
"jest": "^26.0.1",
"lint-staged": "^10.2.9",
"jest": "^26.1.0",
"lint-staged": "^10.2.11",
"memfs": "^3.2.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.0.5",
Expand Down
257 changes: 256 additions & 1 deletion test/__snapshots__/loader.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ const test9 = require('../../src/cjs.js?type=commonjs&exports=single%20Foo!./sim
const test10 = require('../../src/cjs.js?type=commonjs&exports=multiple%20Foo!./simple.js');
const test11 = require('../../src/cjs.js?type=module&exports=named%20Foo%20FooA!./simple.js');
const test12 = require('../../src/cjs.js?type=module&exports[]=named|Foo%20FooA&exports[]=named%20Bar%20BarA!./simple.js');
const test13 = require('../../src/cjs.js?type=module&exports[]=named|Foo|FooA&exports[]=named|Bar|BarA!./simple.js');
const test14 = require('../../src/cjs.js?type=module&exports=default|Foo!./simple.js');
module.exports = {
test1,
Expand All @@ -76,7 +78,9 @@ module.exports = {
test9,
test10,
test11,
test12
test12,
test13,
test14
};
"
`;
Expand Down Expand Up @@ -111,6 +115,24 @@ Object {
"Image": [Function],
},
},
"test13": Object {
"BarA": Object {
"test": Array [
1,
2,
3,
4,
],
},
"FooA": Object {
"Image": [Function],
},
},
"test14": Object {
"default": Object {
"Image": [Function],
},
},
"test2": Object {
"Bar": Object {
"test": Array [
Expand Down Expand Up @@ -992,6 +1014,145 @@ Object {

exports[`loader should work with the "commonjs" module format for "multiple Foo" export list: warnings 1`] = `Array []`;

exports[`loader should work with the "commonjs" module format for "multiple|[name] [name]A" export list: errors 1`] = `Array []`;

exports[`loader should work with the "commonjs" module format for "multiple|[name] [name]A" export list: module 1`] = `
"var Foo = Foo || {};
var Bar = Bar || {};
var Baz = {
nestedNumber: '12',
nestedFunction: function test() {}
};
var simple = function simple() {};
var simple_foo = [1, 2, 3, 4, 5];
Foo.Image = function(width, height, data){
this.width = width || 0;
this.height = height || 0;
this.data = data || [];
};
Bar.test = [1, 2, 3, 4];
class MyClass {
myFunction() {
return 12;
}
}
const single = 'single';
const myVariable = new MyClass();
/*** EXPORTS FROM exports-loader ***/
module.exports = {
\\"simpleA\\": (simple)
};
"
`;

exports[`loader should work with the "commonjs" module format for "multiple|[name] [name]A" export list: result 1`] = `
Object {
"simpleA": [Function],
}
`;

exports[`loader should work with the "commonjs" module format for "multiple|[name] [name]A" export list: warnings 1`] = `Array []`;

exports[`loader should work with the "commonjs" module format for "multiple|Foo" export list: errors 1`] = `Array []`;

exports[`loader should work with the "commonjs" module format for "multiple|Foo" export list: module 1`] = `
"var Foo = Foo || {};
var Bar = Bar || {};
var Baz = {
nestedNumber: '12',
nestedFunction: function test() {}
};
var simple = function simple() {};
var simple_foo = [1, 2, 3, 4, 5];
Foo.Image = function(width, height, data){
this.width = width || 0;
this.height = height || 0;
this.data = data || [];
};
Bar.test = [1, 2, 3, 4];
class MyClass {
myFunction() {
return 12;
}
}
const single = 'single';
const myVariable = new MyClass();
/*** EXPORTS FROM exports-loader ***/
module.exports = {
Foo
};
"
`;

exports[`loader should work with the "commonjs" module format for "multiple|Foo" export list: result 1`] = `
Object {
"Foo": Object {
"Image": [Function],
},
}
`;

exports[`loader should work with the "commonjs" module format for "multiple|Foo" export list: warnings 1`] = `Array []`;

exports[`loader should work with the "commonjs" module format for "multiple|Foo|FooA" export list: errors 1`] = `Array []`;

exports[`loader should work with the "commonjs" module format for "multiple|Foo|FooA" export list: module 1`] = `
"var Foo = Foo || {};
var Bar = Bar || {};
var Baz = {
nestedNumber: '12',
nestedFunction: function test() {}
};
var simple = function simple() {};
var simple_foo = [1, 2, 3, 4, 5];
Foo.Image = function(width, height, data){
this.width = width || 0;
this.height = height || 0;
this.data = data || [];
};
Bar.test = [1, 2, 3, 4];
class MyClass {
myFunction() {
return 12;
}
}
const single = 'single';
const myVariable = new MyClass();
/*** EXPORTS FROM exports-loader ***/
module.exports = {
\\"FooA\\": (Foo)
};
"
`;

exports[`loader should work with the "commonjs" module format for "multiple|Foo|FooA" export list: result 1`] = `
Object {
"FooA": Object {
"Image": [Function],
},
}
`;

exports[`loader should work with the "commonjs" module format for "multiple|Foo|FooA" export list: warnings 1`] = `Array []`;

exports[`loader should work with the "commonjs" module format for "named Foo" export list: errors 1`] = `
Array [
"ModuleBuildError: Module build failed (from \`replaced original path\`):
Expand Down Expand Up @@ -2052,6 +2213,100 @@ Object {

exports[`loader should work with the "module" module format for "named|[name] [name]A" export list: warnings 1`] = `Array []`;

exports[`loader should work with the "module" module format for "named|Foo" export list: errors 1`] = `Array []`;

exports[`loader should work with the "module" module format for "named|Foo" export list: module 1`] = `
"var Foo = Foo || {};
var Bar = Bar || {};
var Baz = {
nestedNumber: '12',
nestedFunction: function test() {}
};
var simple = function simple() {};
var simple_foo = [1, 2, 3, 4, 5];
Foo.Image = function(width, height, data){
this.width = width || 0;
this.height = height || 0;
this.data = data || [];
};
Bar.test = [1, 2, 3, 4];
class MyClass {
myFunction() {
return 12;
}
}
const single = 'single';
const myVariable = new MyClass();
/*** EXPORTS FROM exports-loader ***/
export {
Foo
};
"
`;

exports[`loader should work with the "module" module format for "named|Foo" export list: result 1`] = `
Object {
"Foo": Object {
"Image": [Function],
},
}
`;

exports[`loader should work with the "module" module format for "named|Foo" export list: warnings 1`] = `Array []`;

exports[`loader should work with the "module" module format for "named|Foo|FooA" export list: errors 1`] = `Array []`;

exports[`loader should work with the "module" module format for "named|Foo|FooA" export list: module 1`] = `
"var Foo = Foo || {};
var Bar = Bar || {};
var Baz = {
nestedNumber: '12',
nestedFunction: function test() {}
};
var simple = function simple() {};
var simple_foo = [1, 2, 3, 4, 5];
Foo.Image = function(width, height, data){
this.width = width || 0;
this.height = height || 0;
this.data = data || [];
};
Bar.test = [1, 2, 3, 4];
class MyClass {
myFunction() {
return 12;
}
}
const single = 'single';
const myVariable = new MyClass();
/*** EXPORTS FROM exports-loader ***/
export {
Foo as FooA
};
"
`;

exports[`loader should work with the "module" module format for "named|Foo|FooA" export list: result 1`] = `
Object {
"FooA": Object {
"Image": [Function],
},
}
`;

exports[`loader should work with the "module" module format for "named|Foo|FooA" export list: warnings 1`] = `Array []`;

exports[`loader should work with the "module" module format for "single Foo" export list: errors 1`] = `
Array [
"ModuleBuildError: Module build failed (from \`replaced original path\`):
Expand Down
Loading

0 comments on commit 7829c1b

Please sign in to comment.