Webpack์ผ๋ก ํธ๋ค๋ฐ๋ฅผ ๋ก๋ํ ๋ ์ด๋ฌํ ๊ฒฝ๊ณ ๋ฅผ ์ ๊ฑฐํ๊ฑฐ๋ ๋นํ์ฑํํ๋ ๋ฐฉ๋ฒ์ด ์์ต๋๊น?
./~/handlebars/lib/index.js์ ๊ฒฝ๊ณ
require.extensions๋ ์นํฉ์์ ์ง์ํ์ง ์์ต๋๋ค. ๋์ ๋ก๋๋ฅผ ์ฌ์ฉํ์ญ์์ค.
./~/handlebars/lib/index.js์ ๊ฒฝ๊ณ
require.extensions๋ ์นํฉ์์ ์ง์ํ์ง ์์ต๋๋ค. ๋์ ๋ก๋๋ฅผ ์ฌ์ฉํ์ญ์์ค.
./~/handlebars/lib/index.js์ ๊ฒฝ๊ณ
require.extensions๋ ์นํฉ์์ ์ง์ํ์ง ์์ต๋๋ค. ๋์ ๋ก๋๋ฅผ ์ฌ์ฉํ์ญ์์ค.
handlebars-loader์ ๊ฐ์ ๊ฒ์ ์ฌ์ฉํ์ฌ ๋ฏธ๋ฆฌ ์ปดํ์ผํ๊ณ handlebars/runtime
๋ชจ๋์ ์ฌ์ฉํ๋ ๊ฒ์ด ์ข์ต๋๋ค. ๊ทธ๋ ์ง ์์ผ๋ฉด ์ด ๋
ธ๋๋ณ ์ฝ๋๊ฐ ์๊ธฐ ๋๋ฌธ์ bower๋ฅผ ํตํด ํด๋ผ์ด์ธํธ ์ธก ๋น๋ ์ค ํ๋๋ฅผ ์ฌ์ฉํด์ผ ํฉ๋๋ค.
handlebars-loader์ ๊ฐ์ ๊ฒ์ ์ฌ์ฉํ์ฌ ๋ฏธ๋ฆฌ ์ปดํ์ผํ๊ณ handlebars/runtime ๋ชจ๋์ ํ์ฉํ๋ ๊ฒ์ด ์ข์ต๋๋ค.
@kpdecker ์ด๋ป๊ฒ ํ ๊น์? ์ ๋ ํธ๋ค๋ฐ 1.3.0๊ณผ ํธ๋ค๋ฐ-๋ก๋ ^1.0.2๋ฅผ ๋ชจ๋ ์ค์นํ์ผ๋ฉฐ ๋ค์๊ณผ ๊ฐ์ AMD ๋ชจ๋์ด ์์ต๋๋ค.
define([
'hbs!path/to/template' // path/to/template.hbs
],
function(template) {
// ...
});
๊ทธ๋ฆฌ๊ณ webpack ๊ตฌ์ฑ์๋ ๋ค์์ด ์์ต๋๋ค.
{
resolveLoader: {
fallback: path.join(__dirname, 'node_modules'),
alias: {
'hbs': 'handlebars-loader'
}
},
}
hbs!
๊ฐ ํธ๋ค๋ฐ ๋ก๋์ ๋งคํ๋๋๋ก ํฉ๋๋ค. ๊ทธ๋ฐ ๋ค์ webpack์ ์คํํ๋ฉด ๋ค์๊ณผ ๊ฐ์ ์น์ํ ๊ฒฝ๊ณ ๊ฐ ํ์๋ฉ๋๋ค.
WARNING in /some/absolute/path/~/handlebars/lib/index.js
require.extensions is not supported by webpack. Use a loader instead.
๋ด๊ฐ ๋ฌด์์ ๋์น๊ณ ์์ต๋๊น? handlebars/runtime
๋ก ๋ฌด์์ ํด์ผ ํฉ๋๊น?
์ข์ต๋๋ค. ํธ๋ค๋ฐ์ ๋ณ์นญ์ ์ถ๊ฐํ๋ฉด ๊ฒฝ๊ณ ๊ฐ ์ ๊ฑฐ๋ ๊ฒ ๊ฐ์ต๋๋ค.
{
resolve: {
modulesDirectories: ['node_modules', 'src'],
fallback: path.join(__dirname, 'node_modules'),
alias: {
'handlebars': 'handlebars/runtime.js'
}
},
resolveLoader: {
fallback: path.join(__dirname, 'node_modules'),
alias: {
'hbs': 'handlebars-loader'
}
}
}
๊ทธ๊ฒ์ ์์์์ธ ๊ฒ ๊ฐ์ง๋ง, ๋๋ ์ฌ์ ํ ์ด๋ค ๊ฒ์ด ์คํ๋๊ธฐ ์ ์ ์์๋ด์ผ ํ ๋ค๋ฅธ ์ค๋ฅ๊ฐ ์์ต๋๋ค. ๊ทธ๋ฌ๋ฉด ์ด๊ฒ์ด ์๋ํ๋์ง ์ ์ ์์ ๊ฒ์ ๋๋ค.
์๋ ํ์ธ์, @kpdecker ์ ๋๋ค .
์๊ฒฌ์ ๋ณด๋ด ์ฃผ์
์ ๊ฐ์ฌํฉ๋๋ค.
๊ทธ๊ฒ์ ์ผ์ข
์ ์๋ํฉ๋๋ค.
๋์ผํ ๋ฌธ์ ๊ฐ ์์ต๋๋ค. @trusktr ์ "resolve" ์น์ ('handlebars/runtime.js')์ ์ถ๊ฐํ๋ฉด webpack์ ์คํํ๊ณ "Handlebars.compile์ ํจ์๊ฐ ์๋๋๋ค"๋ผ๋ ๋ฉ์์ง๊ฐ ํ์๋ฉ๋๋ค.
๋ด๊ฐ ๋์น ๊ฒ์ด ์์ต๋๊น?
๋ง์ ๊ฐ์ฌ
๋ฐํ์์๋ ์ปดํ์ผ๋ฌ๊ฐ ํฌํจ๋์ด ์์ง ์์ต๋๋ค. ๋ชจ๋ฒ ์ฌ๋ก์ธ ํ
ํ๋ฆฟ์ ๋ฏธ๋ฆฌ ์ปดํ์ผํด์ผ ํฉ๋๋ค. ํด๋ผ์ด์ธํธ์์ ํ
ํ๋ฆฟ์ ์ปดํ์ผํด์ผ ํ๊ณ ๋น์ฉ(์์ ๋ฐ ํ์ผ ํฌ๊ธฐ)์ ๋ฌธ์ ๊ฐ ์๋ค๋ฉด handlebars/dist/handlebars.js
์ ๊ฐ์ด ํธ๋ค๋ฐ์ ๋ณ์นญ์ ์ง์ ํ๊ณ ์ถ์ ๊ฒ์
๋๋ค.
@kpdecker ๊ฐ์ฌํฉ๋๋ค.
๋๋ ๊ทธ๊ฒ์ ์๋ ํ ๊ฒ์ด๋ค
๋๋ ๋ํ ์ ์ฒด ๋ฐํ์์ ์ํ๋ ์ฌ๋๋ค์ ์ํด ์ด๊ฒ์ด ๋ ๊น๋ํด์ง ์ ์๋์ง ์์๋ณด๊ธฐ ์ํด #1102๋ฅผ ์ ์ถํ์ต๋๋ค.
@kpdecker @seeliang : ์จ๋ฆฌ์ด์ฑ ํธ๋ค๋ฐ๊ฐ ์๋ํ๋ค๋ ๊ฒ์ ๋ค๋ฅธ ์ฌ๋๋ค์๊ฒ ์๋ฆฌ๊ณ ์ถ์ต๋๋ค.
resolve:
{
alias: {
'handlebars' : 'handlebars/dist/handlebars.js'
}
},
@kpdecker ๊ฐ์ฌํฉ๋๋ค.
์ฌ๊ธฐ๋ฅผ ์ฐพ๋ ๋ค๋ฅธ ์ฌ๋๋ค์ ์ํด
์ด๊ฒ์ ๋ด๊ฐ ์ฐพ์ ์ต๊ณ ์ ์๋ฃจ์
์
๋๋ค
https://github.com/valtech-nyc/brookjs/blob/master/packages/brookjs/webpack.config.js#L39 -L43
์ฌ๊ธฐ https://github.com/pcardune/handlebars-loader/issues/110#issuecomment -358681867
@mAAdhaTTah ๋๋ถ์
์ํฅ:
//fix handlebars warnings
config.resolve.alias = {
...config.resolve.alias,
'handlebars/runtime': 'handlebars/dist/cjs/handlebars.runtime',
'handlebars': 'handlebars/dist/cjs/handlebars.runtime',
};
const nodeExternals = require('webpack-node-externals');
module.exports = {
externals: [nodeExternals()]
}
๋ํ ์๋ํฉ๋๋ค.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
@kpdecker @seeliang : ์จ๋ฆฌ์ด์ฑ ํธ๋ค๋ฐ๊ฐ ์๋ํ๋ค๋ ๊ฒ์ ๋ค๋ฅธ ์ฌ๋๋ค์๊ฒ ์๋ฆฌ๊ณ ์ถ์ต๋๋ค.
@kpdecker ๊ฐ์ฌํฉ๋๋ค.