-
Notifications
You must be signed in to change notification settings - Fork 59
refactor: apply webpack defaults #51
base: master
Are you sure you want to change the base?
Changes from 1 commit
8bdc955
cc44e20
8180075
64dc936
d054559
d01293d
4cbaf02
03b2b77
67f4ea4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| { | ||
| "presets": [ | ||
| [ | ||
| "env", | ||
| { | ||
| "useBuiltIns": true, | ||
| "targets": { | ||
| "node": 4.3 | ||
| }, | ||
| "exclude": [ | ||
| "transform-async-to-generator", | ||
| "transform-regenerator" | ||
| ] | ||
| } | ||
| ] | ||
| ], | ||
| "plugins": [ | ||
| [ | ||
| "transform-object-rest-spread", | ||
| { | ||
| "useBuiltIns": true | ||
| } | ||
| ] | ||
| ], | ||
| "env": { | ||
| "test": { | ||
| "presets": [ | ||
| "env" | ||
| ], | ||
| "plugins": [ | ||
| "transform-object-rest-spread" | ||
| ] | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # editorconfig.org | ||
|
|
||
| [*] | ||
| charset = utf-8 | ||
| indent_style = space | ||
| indent_size = 2 | ||
| end_of_line = lf | ||
| insert_final_newline = true | ||
| trim_trailing_whitespace = true | ||
|
|
||
| [.md] | ||
| insert_final_newline = false | ||
| trim_trailing_whitespace = false |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| /node_modules | ||
| /dist |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "extends": "webpack", | ||
| "rules": { | ||
| "no-template-curly-in-string": 0 | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| yarn.lock -diff | ||
| * text=auto | ||
| bin/* eol=lf |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| <!-- | ||
| 1. Check the version of package you are using. If it's not the newest version, update and try again (see changelog while updating!). | ||
| 2. If the issue is still there, write a minimal project showing the problem and expected output. | ||
| 3. Link to the project and mention Node version and OS in your report. | ||
|
|
||
| **IMPORTANT! You should use [Stack Overflow](https://stackoverflow.com/) for support related questions.** | ||
| --> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| <!-- | ||
| 1. [Read and sign the CLA](https://cla.js.foundation/webpack/webpack.js.org). This needs to be done only once. PRs that haven't signed it won't be accepted. | ||
| 2. Check out the [development guide](https://webpack.js.org/development/) for the API and development guidelines. | ||
| 3. Read through the PR diff carefully as sometimes this can reveal issues. The work will be reviewed, but this can save some effort. | ||
| --> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,18 @@ | ||
| node_modules | ||
|
|
||
| logs | ||
| *.log | ||
| npm-debug.log* | ||
| yarn-debug.log* | ||
| .eslintcache | ||
| /coverage | ||
| /dist | ||
| /local | ||
| /reports | ||
| /node_modules | ||
| .DS_Store | ||
| Thumbs.db | ||
| .idea | ||
| .vscode | ||
| *.sublime-project | ||
| *.sublime-workspace |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| sudo: false | ||
| language: node_js | ||
| branches: | ||
| only: | ||
| - master | ||
| matrix: | ||
| fast_finish: true | ||
| include: | ||
| - os: linux | ||
| node_js: '7' | ||
| env: WEBPACK_VERSION="2.2.0" JOB_PART=lint | ||
| - os: linux | ||
| node_js: '4.3' | ||
| env: WEBPACK_VERSION="2.2.0" JOB_PART=test | ||
| - os: linux | ||
| node_js: '6' | ||
| env: WEBPACK_VERSION="2.2.0" JOB_PART=test | ||
| - os: linux | ||
| node_js: '7' | ||
| env: WEBPACK_VERSION="2.2.0" JOB_PART=coverage | ||
| before_install: | ||
| - nvm --version | ||
| - node --version | ||
| before_script: | ||
| - |- | ||
| if [ "$WEBPACK_VERSION" ]; then | ||
| yarn add webpack@^$WEBPACK_VERSION | ||
| fi | ||
| script: | ||
| - 'yarn run travis:$JOB_PART' | ||
| after_success: | ||
| - 'bash <(curl -s https://codecov.io/bash)' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # Change Log | ||
|
|
||
| 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. | ||
|
|
||
| x.x.x / <year>-<month>-<day> | ||
| ================== | ||
|
|
||
| * Bug fix - | ||
| * Feature - | ||
| * Chore - | ||
| * Docs - |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| module.exports = require('./index').default; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| /* | ||
| MIT License http://www.opensource.org/licenses/mit-license.php | ||
| Author Tobias Koppers @sokra | ||
| */ | ||
| import loaderUtils from 'loader-utils'; | ||
|
|
||
| export function pitch(remainingRequest) { // eslint-disable-line no-unused-vars | ||
| const query = loaderUtils.getOptions(this) || {}; | ||
|
|
||
| let chunkNameParam = ''; | ||
|
|
||
| if (query.name) { | ||
| const options = { | ||
| context: query.context || this.options.context, | ||
| regExp: query.regExp, | ||
| }; | ||
| const chunkName = loaderUtils.interpolateName(this, query.name, options); | ||
| chunkNameParam = `, ${JSON.stringify(chunkName)}`; | ||
| } | ||
|
|
||
| let result; | ||
| if (query.lazy) { | ||
|
||
| result = [ | ||
| 'module.exports = function(cb) {\n', | ||
| ' require.ensure([], function(require) {\n', | ||
| ' cb(require(", loaderUtils.stringifyRequest(this, `!!${remainingRequest}`), "));\n', | ||
| ` }${chunkNameParam});\n`, | ||
| '}']; | ||
| } else { | ||
| result = [ | ||
| 'var cbs = [], \n', | ||
| ' data;\n', | ||
| 'module.exports = function(cb) {\n', | ||
| ' if(cbs) cbs.push(cb);\n', | ||
| ' else cb(data);\n', | ||
| '}\n', | ||
| 'require.ensure([], function(require) {\n', | ||
| ' data = require(", loaderUtils.stringifyRequest(this, `!!${remainingRequest}`), ");\n', | ||
| ' var callbacks = cbs;\n', | ||
| ' cbs = null;\n', | ||
| ' for(var i = 0, l = callbacks.length; i < l; i++) {\n', | ||
| ' callbacks[i](data);\n', | ||
| ' }\n', | ||
| `}${chunkNameParam});`]; | ||
| } | ||
| return result.join(''); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
|
|
||
| export default () => { }; | ||
|
|
||
| /* | ||
| Output format: | ||
|
|
||
| var cbs = [], | ||
| data; | ||
| module.exports = function(cb) { | ||
| if(cbs) cbs.push(cb); | ||
| else cb(data); | ||
| } | ||
| require.ensure([], function(require) { | ||
| data = require("xxx"); | ||
| var callbacks = cbs; | ||
| cbs = null; | ||
| for(var i = 0, l = callbacks.length; i < l; i++) { | ||
| callbacks[i](data); | ||
| } | ||
| }); | ||
|
|
||
| */ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import { name as PROJECT_NAME } from '../package.json'; | ||
| import BundleLoader from '../src'; | ||
|
|
||
| describe(PROJECT_NAME, () => { | ||
| test('should export the loader', (done) => { | ||
| expect(BundleLoader).toBeInstanceOf(Function); | ||
| done(); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick 😛
query=>options