Skip to content

Commit 7829c1b

Browse files
chore(release): 1.1.0
1 parent e0bc930 commit 7829c1b

File tree

7 files changed

+1418
-1153
lines changed

7 files changed

+1418
-1153
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
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.
44

5+
## [1.1.0](https://github.com/webpack-contrib/exports-loader/compare/v1.0.1...v1.1.0) (2020-06-24)
6+
7+
8+
### Features
9+
10+
* "|" 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))
11+
512
## [1.0.1](https://github.com/webpack-contrib/exports-loader/compare/v1.0.0...v1.0.1) (2020-06-17)
613

714

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ For further hints on compatibility issues, check out [Shimming](https://webpack.
2222

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

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

3535
### Inline
3636

37-
The `|` or `%20` (space) separate command parts.
38-
39-
> `%20` is space in a query string, because you can't use spaces in URLs
40-
41-
Then add the loader to the desired `require` calls. For example:
37+
Then add the loader to the desired `import` statemtnt and `require` calls. For example:
4238

4339
```js
4440
import { myFunction } from 'exports-loader?exports=myFunction!./file.js';
@@ -85,8 +81,14 @@ const {
8581
myFunction('Hello world');
8682
```
8783

84+
The `|` or `%20` (space) allow to separate the [`syntax`](#syntax), [`name`](#name) and [`alias`](#alias) of export.
85+
86+
> `%20` is space in a query string, because you can't use spaces in URLs
87+
8888
```js
89-
import myFunction from 'exports-loader?exports=default%20myFunction!./file.js';
89+
// Alternative syntax:
90+
// import myFunction from 'exports-loader?exports=default%20myFunction!./file.js';
91+
import myFunction from 'exports-loader?exports=default|myFunction!./file.js';
9092
// `%20` is space in a query string, equivalently `default myFunction`
9193
// Adds the following code to the file's source:
9294
//

package-lock.json

Lines changed: 1126 additions & 1134 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "exports-loader",
3-
"version": "1.0.1",
3+
"version": "1.1.0",
44
"description": "exports loader module for webpack",
55
"license": "MIT",
66
"repository": "webpack-contrib/exports-loader",
@@ -46,24 +46,24 @@
4646
"source-map": "^0.6.1"
4747
},
4848
"devDependencies": {
49-
"@babel/cli": "^7.10.1",
50-
"@babel/core": "^7.10.2",
51-
"@babel/preset-env": "^7.10.2",
52-
"@commitlint/cli": "^8.3.5",
53-
"@commitlint/config-conventional": "^8.3.4",
49+
"@babel/cli": "^7.10.3",
50+
"@babel/core": "^7.10.3",
51+
"@babel/preset-env": "^7.10.3",
52+
"@commitlint/cli": "^9.0.1",
53+
"@commitlint/config-conventional": "^9.0.1",
5454
"@webpack-contrib/defaults": "^6.3.0",
5555
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
56-
"babel-jest": "^26.0.1",
56+
"babel-jest": "^26.1.0",
5757
"babel-loader": "^8.1.0",
5858
"cross-env": "^7.0.2",
5959
"del": "^5.1.0",
6060
"del-cli": "^3.0.1",
61-
"eslint": "^7.2.0",
61+
"eslint": "^7.3.1",
6262
"eslint-config-prettier": "^6.11.0",
6363
"eslint-plugin-import": "^2.21.2",
6464
"husky": "^4.2.5",
65-
"jest": "^26.0.1",
66-
"lint-staged": "^10.2.9",
65+
"jest": "^26.1.0",
66+
"lint-staged": "^10.2.11",
6767
"memfs": "^3.2.0",
6868
"npm-run-all": "^4.1.5",
6969
"prettier": "^2.0.5",

test/__snapshots__/loader.test.js.snap

Lines changed: 256 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ const test9 = require('../../src/cjs.js?type=commonjs&exports=single%20Foo!./sim
6363
const test10 = require('../../src/cjs.js?type=commonjs&exports=multiple%20Foo!./simple.js');
6464
const test11 = require('../../src/cjs.js?type=module&exports=named%20Foo%20FooA!./simple.js');
6565
const test12 = require('../../src/cjs.js?type=module&exports[]=named|Foo%20FooA&exports[]=named%20Bar%20BarA!./simple.js');
66+
const test13 = require('../../src/cjs.js?type=module&exports[]=named|Foo|FooA&exports[]=named|Bar|BarA!./simple.js');
67+
const test14 = require('../../src/cjs.js?type=module&exports=default|Foo!./simple.js');
6668
6769
module.exports = {
6870
test1,
@@ -76,7 +78,9 @@ module.exports = {
7678
test9,
7779
test10,
7880
test11,
79-
test12
81+
test12,
82+
test13,
83+
test14
8084
};
8185
"
8286
`;
@@ -111,6 +115,24 @@ Object {
111115
"Image": [Function],
112116
},
113117
},
118+
"test13": Object {
119+
"BarA": Object {
120+
"test": Array [
121+
1,
122+
2,
123+
3,
124+
4,
125+
],
126+
},
127+
"FooA": Object {
128+
"Image": [Function],
129+
},
130+
},
131+
"test14": Object {
132+
"default": Object {
133+
"Image": [Function],
134+
},
135+
},
114136
"test2": Object {
115137
"Bar": Object {
116138
"test": Array [
@@ -992,6 +1014,145 @@ Object {
9921014

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

1017+
exports[`loader should work with the "commonjs" module format for "multiple|[name] [name]A" export list: errors 1`] = `Array []`;
1018+
1019+
exports[`loader should work with the "commonjs" module format for "multiple|[name] [name]A" export list: module 1`] = `
1020+
"var Foo = Foo || {};
1021+
var Bar = Bar || {};
1022+
var Baz = {
1023+
nestedNumber: '12',
1024+
nestedFunction: function test() {}
1025+
};
1026+
var simple = function simple() {};
1027+
var simple_foo = [1, 2, 3, 4, 5];
1028+
1029+
Foo.Image = function(width, height, data){
1030+
this.width = width || 0;
1031+
this.height = height || 0;
1032+
this.data = data || [];
1033+
};
1034+
1035+
Bar.test = [1, 2, 3, 4];
1036+
1037+
class MyClass {
1038+
myFunction() {
1039+
return 12;
1040+
}
1041+
}
1042+
1043+
const single = 'single';
1044+
1045+
const myVariable = new MyClass();
1046+
1047+
/*** EXPORTS FROM exports-loader ***/
1048+
module.exports = {
1049+
\\"simpleA\\": (simple)
1050+
};
1051+
"
1052+
`;
1053+
1054+
exports[`loader should work with the "commonjs" module format for "multiple|[name] [name]A" export list: result 1`] = `
1055+
Object {
1056+
"simpleA": [Function],
1057+
}
1058+
`;
1059+
1060+
exports[`loader should work with the "commonjs" module format for "multiple|[name] [name]A" export list: warnings 1`] = `Array []`;
1061+
1062+
exports[`loader should work with the "commonjs" module format for "multiple|Foo" export list: errors 1`] = `Array []`;
1063+
1064+
exports[`loader should work with the "commonjs" module format for "multiple|Foo" export list: module 1`] = `
1065+
"var Foo = Foo || {};
1066+
var Bar = Bar || {};
1067+
var Baz = {
1068+
nestedNumber: '12',
1069+
nestedFunction: function test() {}
1070+
};
1071+
var simple = function simple() {};
1072+
var simple_foo = [1, 2, 3, 4, 5];
1073+
1074+
Foo.Image = function(width, height, data){
1075+
this.width = width || 0;
1076+
this.height = height || 0;
1077+
this.data = data || [];
1078+
};
1079+
1080+
Bar.test = [1, 2, 3, 4];
1081+
1082+
class MyClass {
1083+
myFunction() {
1084+
return 12;
1085+
}
1086+
}
1087+
1088+
const single = 'single';
1089+
1090+
const myVariable = new MyClass();
1091+
1092+
/*** EXPORTS FROM exports-loader ***/
1093+
module.exports = {
1094+
Foo
1095+
};
1096+
"
1097+
`;
1098+
1099+
exports[`loader should work with the "commonjs" module format for "multiple|Foo" export list: result 1`] = `
1100+
Object {
1101+
"Foo": Object {
1102+
"Image": [Function],
1103+
},
1104+
}
1105+
`;
1106+
1107+
exports[`loader should work with the "commonjs" module format for "multiple|Foo" export list: warnings 1`] = `Array []`;
1108+
1109+
exports[`loader should work with the "commonjs" module format for "multiple|Foo|FooA" export list: errors 1`] = `Array []`;
1110+
1111+
exports[`loader should work with the "commonjs" module format for "multiple|Foo|FooA" export list: module 1`] = `
1112+
"var Foo = Foo || {};
1113+
var Bar = Bar || {};
1114+
var Baz = {
1115+
nestedNumber: '12',
1116+
nestedFunction: function test() {}
1117+
};
1118+
var simple = function simple() {};
1119+
var simple_foo = [1, 2, 3, 4, 5];
1120+
1121+
Foo.Image = function(width, height, data){
1122+
this.width = width || 0;
1123+
this.height = height || 0;
1124+
this.data = data || [];
1125+
};
1126+
1127+
Bar.test = [1, 2, 3, 4];
1128+
1129+
class MyClass {
1130+
myFunction() {
1131+
return 12;
1132+
}
1133+
}
1134+
1135+
const single = 'single';
1136+
1137+
const myVariable = new MyClass();
1138+
1139+
/*** EXPORTS FROM exports-loader ***/
1140+
module.exports = {
1141+
\\"FooA\\": (Foo)
1142+
};
1143+
"
1144+
`;
1145+
1146+
exports[`loader should work with the "commonjs" module format for "multiple|Foo|FooA" export list: result 1`] = `
1147+
Object {
1148+
"FooA": Object {
1149+
"Image": [Function],
1150+
},
1151+
}
1152+
`;
1153+
1154+
exports[`loader should work with the "commonjs" module format for "multiple|Foo|FooA" export list: warnings 1`] = `Array []`;
1155+
9951156
exports[`loader should work with the "commonjs" module format for "named Foo" export list: errors 1`] = `
9961157
Array [
9971158
"ModuleBuildError: Module build failed (from \`replaced original path\`):
@@ -2052,6 +2213,100 @@ Object {
20522213

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

2216+
exports[`loader should work with the "module" module format for "named|Foo" export list: errors 1`] = `Array []`;
2217+
2218+
exports[`loader should work with the "module" module format for "named|Foo" export list: module 1`] = `
2219+
"var Foo = Foo || {};
2220+
var Bar = Bar || {};
2221+
var Baz = {
2222+
nestedNumber: '12',
2223+
nestedFunction: function test() {}
2224+
};
2225+
var simple = function simple() {};
2226+
var simple_foo = [1, 2, 3, 4, 5];
2227+
2228+
Foo.Image = function(width, height, data){
2229+
this.width = width || 0;
2230+
this.height = height || 0;
2231+
this.data = data || [];
2232+
};
2233+
2234+
Bar.test = [1, 2, 3, 4];
2235+
2236+
class MyClass {
2237+
myFunction() {
2238+
return 12;
2239+
}
2240+
}
2241+
2242+
const single = 'single';
2243+
2244+
const myVariable = new MyClass();
2245+
2246+
/*** EXPORTS FROM exports-loader ***/
2247+
export {
2248+
Foo
2249+
};
2250+
"
2251+
`;
2252+
2253+
exports[`loader should work with the "module" module format for "named|Foo" export list: result 1`] = `
2254+
Object {
2255+
"Foo": Object {
2256+
"Image": [Function],
2257+
},
2258+
}
2259+
`;
2260+
2261+
exports[`loader should work with the "module" module format for "named|Foo" export list: warnings 1`] = `Array []`;
2262+
2263+
exports[`loader should work with the "module" module format for "named|Foo|FooA" export list: errors 1`] = `Array []`;
2264+
2265+
exports[`loader should work with the "module" module format for "named|Foo|FooA" export list: module 1`] = `
2266+
"var Foo = Foo || {};
2267+
var Bar = Bar || {};
2268+
var Baz = {
2269+
nestedNumber: '12',
2270+
nestedFunction: function test() {}
2271+
};
2272+
var simple = function simple() {};
2273+
var simple_foo = [1, 2, 3, 4, 5];
2274+
2275+
Foo.Image = function(width, height, data){
2276+
this.width = width || 0;
2277+
this.height = height || 0;
2278+
this.data = data || [];
2279+
};
2280+
2281+
Bar.test = [1, 2, 3, 4];
2282+
2283+
class MyClass {
2284+
myFunction() {
2285+
return 12;
2286+
}
2287+
}
2288+
2289+
const single = 'single';
2290+
2291+
const myVariable = new MyClass();
2292+
2293+
/*** EXPORTS FROM exports-loader ***/
2294+
export {
2295+
Foo as FooA
2296+
};
2297+
"
2298+
`;
2299+
2300+
exports[`loader should work with the "module" module format for "named|Foo|FooA" export list: result 1`] = `
2301+
Object {
2302+
"FooA": Object {
2303+
"Image": [Function],
2304+
},
2305+
}
2306+
`;
2307+
2308+
exports[`loader should work with the "module" module format for "named|Foo|FooA" export list: warnings 1`] = `Array []`;
2309+
20552310
exports[`loader should work with the "module" module format for "single Foo" export list: errors 1`] = `
20562311
Array [
20572312
"ModuleBuildError: Module build failed (from \`replaced original path\`):

0 commit comments

Comments
 (0)