Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(putout) add bundle dist/putout.js
- Loading branch information
1 parent
9b39f10
commit d0652b1
Showing
9 changed files
with
126 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"plugins": [ | ||
"module:babel-plugin-macros", | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict'; | ||
|
||
require('module'); | ||
module.exports = require('../lib/putout'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict'; | ||
|
||
module.exports._findPath = (a) => a; | ||
|
||
const codegen = require('codegen.macro'); | ||
module.exports.plugins = codegen`module.exports = require('./require-all')();`; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
'use strict'; | ||
|
||
const {plugins} = require('../putout.json'); | ||
|
||
module.exports = () => { | ||
const result = plugins | ||
.map((a) => `plugins['${a}'] = require('@putout/plugin-${a}');`) | ||
.join('\n'); | ||
|
||
return ` | ||
const plugins = {}; | ||
${result}; | ||
return plugins; | ||
` | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
'use strict'; | ||
|
||
const path = require('path'); | ||
const webpack = require('webpack'); | ||
const dir = './lib'; | ||
|
||
const {env} = process; | ||
const isDev = env.NODE_ENV === 'development'; | ||
|
||
const dist = path.resolve(__dirname, '..', 'dist'); | ||
const distDev = path.resolve(__dirname, '..', 'dist-dev'); | ||
const devtool = isDev ? 'eval' : 'source-map'; | ||
|
||
const babelDev = { | ||
plugins: [ | ||
'module:babel-plugin-macros', | ||
], | ||
}; | ||
|
||
const rules = [{ | ||
test: /\.js$/, | ||
exclude: /node_modules/, | ||
loader: 'babel-loader', | ||
options: babelDev, | ||
}]; | ||
|
||
module.exports = { | ||
devtool, | ||
entry: { | ||
putout: path.join(__dirname, `./index.js`), | ||
}, | ||
output: { | ||
library: 'putout', | ||
filename: '[name].js', | ||
path: isDev ? distDev : dist, | ||
pathinfo: isDev, | ||
libraryTarget: 'umd', | ||
devtoolModuleFilenameTemplate, | ||
}, | ||
plugins: [ | ||
new webpack.IgnorePlugin({ | ||
checkResource(context) { | ||
return /^esprima|fixture|^acorn|espree|tape|@putout\/test/.test(context); | ||
}, | ||
}), | ||
], | ||
module: { | ||
rules, | ||
}, | ||
resolve: { | ||
alias: { | ||
module: path.resolve(__dirname, 'module.js'), | ||
} | ||
}, | ||
performance: { | ||
maxEntrypointSize: 1024000, | ||
maxAssetSize: 1024000, | ||
}, | ||
}; | ||
|
||
function devtoolModuleFilenameTemplate(info) { | ||
const resource = info.absoluteResourcePath.replace(__dirname + path.sep, ''); | ||
return `file://putout/${resource}`; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters