์ ์ถํฉ๋๋ค...
๊ธฐ๋ฅ ์ ์์ฒญํ๊ฑฐ๋ ๋ฒ๊ทธ๋ฅผ ๋ณด๊ณ ํ์๊ฒ ์ต๋๊น?
๋ผ์ด๋ธ๋ฌ๋ฆฌ ๋ฐ Angular Universal ๋น๋ ์ฌ์ ๋ ๋๋ง ๊ธฐ๋ฅ์ ๋ฒ๊ทธ
ํ์ฌ ํ๋์ ๋ฌด์์
๋๊น?
๋ช
๋ น์ ์คํํ ๋:
npm run build:prerender
๊ทธ๊ฒ์ ์๋ํ๋ค:
"generate:prerender": "cd dist && node prerender",
๊ทธ๋ฐ ๋ค์ ์ค๋ฅ์ ํจ๊ป ์คํจํฉ๋๋ค.
```/node_modules/ng-lazyload-image/src/lazyload-image.module.js:1
(ํจ์(๋ด๋ณด๋ด๊ธฐ, ์๊ตฌ, ๋ชจ๋, __filename, __dirname) { import { NgModule } from '@angular/core';
^^^^^^
SyntaxError: ์๊ธฐ์น ์์ ํ ํฐ ๊ฐ์ ธ์ค๊ธฐ
createScript์์(vm.js:80:10)
Object.runInThisContext์์(vm.js:139:10)
Module._compile์์ (module.js:617:28)
Object.Module._extensions..js์์ (module.js:664:10)
Module.load์์ (module.js:566:32)
tryModuleLoad์์(module.js:506:12)
Function.Module._load์์ (module.js:498:3)
Module.require์์ (module.js:597:17)
ํ์ ์(internal/module.js:11:18)
Object.ng-lazyload-image/src/lazyload-image.module์์ (/dist/server/main.js:1350:18)
* **provide the steps to reproduce**
1) Duplicate the Angular Universal starter project from:
https://github.com/angular/universal-starter
2) Add your library, following install instructions:
https://github.com/tjoskar/ng-lazyload-image
3) Run the Angular build command to see the error:
```npm run build:prerender```
* **What is the expected behavior?**
No error, and to continue building.
* **What is the motivation / use case for changing the behavior?**
Otherwise your plugin cannot be used with Angular Universal, which means no static site generation :(
* **Please tell us about your environment:**
- MacOS 10.13.6
- node 8.9.1
- ng-cli 6.0.0 and tested with 7.1.4
- angular 6.0.0 and tested with 7.1.4
- nguniversal 6.0.0 and tested with 7.0.2
* **Other information**
Looks like other people have had similar problems with Angular Universal and third-party libraries such as yours:
https://github.com/angular/angular-cli/issues/7200#issuecomment-329711848
They say the third-party libraries aren't being built correctly, which means Angular Universal fails:
https://github.com/angular/angular-cli/issues/7200#issuecomment-328991769
for example they suggest adding to your package.json
```"main": "./bundles/quickstart-lib.umd.js",
"module": "./quickstart-lib.es5.js",
"es2015": "./quickstart-lib.js",
"typings": "./quickstart-lib.d.ts",
์ ๊ทผ๋ฒ 1
ํ๋ฌ๊ทธ์ธ ๋ฃจํธ ํจ์น:
npm install @babel/cli @babel/core @babel/preset-env @babel/plugin-transform-modules-umd
ํ๋ฌ๊ทธ์ธ ํด๋์ ๋ฃจํธ์ .babelrc ํ์ผ ์ถ๊ฐ:
{
"plugins": [["@babel/plugin-proposal-decorators", { "decoratorsBeforeExport": true }]],
"presets": ["@babel/preset-env"]
}
ํ๋ฌ๊ทธ์ธ package.json ์ ๋ฐ์ดํธ
"main": "./lib-umd/index.js",
"module": "./lib-es5/index.js",
"es2015": "./lib/index.js",
"typings": "./lib/index.d.ts",
"scripts": {
"build:umd": "babel ./lib/*.js --out-dir ./lib-umd --plugins @babel/plugin-transform-modules-umd",
"build:es5": "babel ./lib/*.js --out-dir ./lib-es5"
}
๊ทธ๋ฐ ๋ค์ ๋น๋๋ฅผ ์คํํฉ๋๋ค.
npm run build:es5 && npm run build:umd
๋ด ์์ ์ ํ๋ก์ ํธ tsconfig.json์ ์ถ๊ฐ
"compilerOptions": {
"paths": { "@angular/*": ["../node_modules/@angular/*"] },
}
๊ทธ๋ฌ๋ ์ฌ์ ํ Angular Universal์์ ๋์ผํ ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค.
์ ๊ทผ๋ฒ 2
๋ค์ ์์น์์ ์์ ํ๋ก์ ํธ์ ๋ํ Typescript ๋น๋ ์ต์
์ ์ฌ์ฉํฉ๋๋ค.
https://github.com/filipesilva/angular-quickstart-lib
๋๋ ๋ํ ๊ฐ์ ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค. Angular Universal์ด ์ค์น๋์ด ์์ต๋๋ค.
``` node_modules\ng-lazyload-image\index.js:1
(ํจ์(๋ด๋ณด๋ด๊ธฐ, ์๊ตฌ, ๋ชจ๋, __filename, __dirname) { import { LazyLoadImageDirective } from './src/lazyload-image.directive';
^^^^^^
SyntaxError: ์๊ธฐ์น ์์ ํ ํฐ ๊ฐ์ ธ์ค๊ธฐ
createScript์์(vm.js:80:10)
Object.runInThisContext์์(vm.js:139:10)
Module._compile์์ (module.js:617:28)
Object.Module._extensions..js์์ (module.js:664:10)
Module.load์์ (module.js:566:32)
tryModuleLoad์์(module.js:506:12)
Function.Module._load์์ (module.js:498:3)
Module.require์์ (module.js:597:17)
ํ์ ์(internal/module.js:11:18)
ํ๊ฐ ์ (webpack:///external_%22ng-lazyload-image%22?:1:18) ```
๋๋ Universal๊ณผ ํจ๊ป ์๋ํ๋ ๋ด ์์ ์ ์ง์๋ฌธ์ ์์ฑํ๊ฒ ๋์์ต๋๋ค.
import { Directive, ElementRef, Inject, Input, OnInit, PLATFORM_ID} from '@angular/core';
import { isPlatformBrowser } from '@angular/common';
@Directive({
selector: '[appLazyLoadImage]'
})
export class LazyLoadImageDirective implements OnInit {
@Input() srcLazy: string;
constructor(
private el: ElementRef,
@Inject(PLATFORM_ID) private platformId: Object,
) { }
ngOnInit() {
// only run lazy image loading in the browser
if (isPlatformBrowser(this.platformId)) {
// if browser supports IntersectionObserver
if ('IntersectionObserver' in window) {
const lazyImageObserver = new IntersectionObserver((entries, observer) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
entry.target.setAttribute('src', this.srcLazy);
entry.target.classList.add('lazy-loaded');
lazyImageObserver.unobserve(entry.target);
}
});
});
lazyImageObserver.observe(this.el.nativeElement);
} else {
// Otherwise replace image by default
this.el.nativeElement.setAttribute('src', this.srcLazy);
}
}
}
}
๋ชจ๋๋ก ๊ฐ์ ธ์ค๊ธฐ:
import { LazyLoadImageDirective } from './lazy-load-image.directive';
...
@NgModule({
imports: [
CommonModule
],
declarations: [
LazyLoadImageDirective
],
exports: [
CommonModule,
LazyLoadImageDirective
]
})
...etc
๋ค์์ ์ฌ์ฉํ์ฌ ์ด๋ฏธ์ง์ ์ฌ์ฉ:
<img src="../assets/placeholder.jpg" srcLazy="../assets/myimage.jpg" alt="Example" appLazyLoadImage />
๋๋ ๋ํ ๊ฐ์ ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค. Angular Universal์ด ์ค์น๋์ด ์์ต๋๋ค.
(function (exports, require, module, __filename, __dirname) { import { LazyLoadImageDirective } from './src/lazyload-image.directive'; ^^^^^^ SyntaxError: Unexpected token import at createScript (vm.js:80:10) at Object.runInThisContext (vm.js:139:10) at Module._compile (module.js:617:28) at Object.Module._extensions..js (module.js:664:10) at Module.load (module.js:566:32) at tryModuleLoad (module.js:506:12) at Function.Module._load (module.js:498:3) at Module.require (module.js:597:17) at require (internal/module.js:11:18) at eval (webpack:///external_%22ng-lazyload-image%22?:1:18) ```
์ด๊ฒ์ผ๋ก ์๋
์ด๊ฒ์ webpack ๊ตฌ์ฑ์ ์ถ๊ฐํ์ต๋๋ค.
externals: [ nodeExternals({
whitelist: [
/^ng-lazyload-image/,
]
})
angular universal
๋ ComonJS ๋ชจ๋๋ง ๊ฐ์ ธ์ฌ ์ ์๊ณ ng-lazyload-image
๋ ๋์ angular universal
๋ก ES ๋ชจ๋๋ง ์์ผ๋ฏ๋ก ์คํจํฉ๋๋ค.
@kmturley๊ฐ ์ค๋ช
ํ ๋๋ก ng-lazyload-image
๋ํด ์ฌ๋ฌ ๋์์ ์ค์ ํด์ผ ํ๋ค๊ณ ์๊ฐํฉ๋๋ค. ๊ทธ๋ฌ๋ ๊ทธ๊ฒ์ ๋ํ ๋๋ฌด ํ๋ค๊ธฐ๊ฐ ์๋ํ์ง ์๋๋ค๋ ๊ฒ์ ์๋ฏธํฉ๋๋ค.
@xmasuku , webpack ๊ตฌ์ฑ์ ๋ํ ๋ ์์ธํ ์๋ฅผ ๋ค์ด ์ฃผ์๊ฒ ์ต๋๊น? whitelist
๋ ์ด๋์ ์ฌ์ฉํฉ๋๊น?
@tjoskar ๋ด ์ฌ์ฉ์ ์ ์ webpack ๋น๋๋ฅผ ์ฌ์ฉํ๋๋ฐ angular cli๋ฅผ ์ฌ์ฉํ์ง ์์์ต๋๋ค.
cli ํ๋ก์ ํธ๋ฅผ ์์ฑํ๋๋ฐ ๋์ผํ ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค.
์ข์, ์ค๋ ๋ฐค์ ๊ทธ๊ฒ์ ๋ณด๋ ค๊ณ ๋ ธ๋ ฅํ ๊ฑฐ์ผ
Angular Universal๋ก ๋น๋๋ฅผ ์๋ํ๋ ๋์ ๋์ผํ ๋ฌธ์ ๊ฐ ๋ฐ์ํฉ๋๋ค. @tjoskar ng-packagr
๋ฅผ ์ฌ์ฉํ์ฌ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ๊ตฌ์ถํ๋ ๊ฒ์ ๋ํด ์๊ฐํด ๋ณด์
จ์ต๋๊น ? FESM2015, FESM5 ๋ฐ UMD ํ์์ผ๋ก ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ๋น๋ํ๊ณ ๋ฒ๋คํ ์ ์์ต๋๋ค.
https://github.com/ng-packagr/ng-packaged/blob/master/package.json#L11(ng-packagr์ ์ฌ์ฉํ๋ ์์ ํ๋ก์ ํธ)์ ์ดํด๋ณด์ธ์.
// ๋ณดํธ์ ์ธ ๋ฌธ์ ์ฒ๋ผ ๋ณด์
๋๋ค. ์. https://github.com/angular/angular-cli/issues/7200
// ๋ด ํ๋ก์ ํธ์ ์ด ์ค์ ์ด ์์ต๋๋ค.
// ์ด๊ฒ์ ๋์ฒดํฉ๋๋ค: --- " compile:server ": "tsc -p server.tsconfig.json"
// ๋ค์๊ณผ ํจ๊ป: --- " compile:server ": "node --max_old_space_size=3072 node_modules/webpack/bin/webpack.js --config webpack.server.config.js --progress --colors"
// ๊ทธ๋ฐ ๋ค์ webpack.server.config.js๋ฅผ ๋ง๋ค๊ณ ์๋ ์ฝ๋๋ฅผ ์ถ๊ฐํฉ๋๋ค.
const path = require('path');
const webpack = require('webpack');
const nodeExternals = require('webpack-node-externals');
module.exports = {
mode: 'none',
entry: {
// This is our Express server for Dynamic universal
server: './server.ts'
},
target: 'node',
resolve: { extensions: ['.ts', '.js'] },
externals: [ nodeExternals({
whitelist: [
/^ng-lazyload-image/,
]
}), /.*?webpack.*?/i ],
optimization: {
minimize: false
},
output: {
// Puts the output at the root of the dist folder
path: path.join(__dirname, 'dist'),
filename: '[name].js'
},
module: {
rules: [
{ test: /\.ts$/, loader: 'ts-loader' },
{
// Mark files inside `@angular/core` as using SystemJS style dynamic imports.
// Removing this will cause deprecation warnings to appear.
test: /(\\|\/)@angular(\\|\/)core(\\|\/).+\.js$/,
parser: { system: true },
},
]
},
plugins: [
new webpack.ContextReplacementPlugin(
// fixes WARNING Critical dependency: the request of a dependency is an expression
/(.+)?angular(\\|\/)core(.+)?/,
path.join(__dirname, 'src'), // location of your src
{} // a map of your routes
),
new webpack.ContextReplacementPlugin(
// fixes WARNING Critical dependency: the request of a dependency is an expression
/(.+)?express(\\|\/)(.+)?/,
path.join(__dirname, 'src'),
{}
)
]
};
// ๋ด ์๋ฒ.ts
```
import 'zone.js/dist/zone-node';
'@angular/core'์์ {enableProdMode} ๊ฐ์ ธ์ค๊ธฐ;
// ์ต์คํ๋ ์ค ์์ง
'@nguniversal/express-engine'์์ {ngExpressEngine} ๊ฐ์ ธ์ค๊ธฐ;
// ์ง์ฐ ๋ก๋ฉ์ ์ํ ๋ชจ๋ ๋งต ๊ฐ์ ธ์ค๊ธฐ
'@nguniversal/module-map-ngfactory-loader'์์ {provideModuleMap} ๊ฐ์ ธ์ค๊ธฐ;
import * '์ต์คํ๋ ์ค'์์ ์ต์คํ๋ ์ค๋ก;
'๊ฒฝ๋ก'์์ {join} ๊ฐ์ ธ์ค๊ธฐ;
// ๋ ๋น ๋ฅธ ์๋ฒ ๋ ๋๋ง w/ Prod ๋ชจ๋(๊ฐ๋ฐ ๋ชจ๋๋ ํ์ํ์ง ์์)
enableProdMode();
// ์ต์คํ๋ ์ค ์๋ฒ
const ์ฑ = ์ต์คํ๋ ์ค();
const ํฌํธ = process.env.PORT || 4000;
const DIST_FOLDER = Join(process.cwd(), 'dist/browser');
// * ์ฐธ๊ณ : ์ด ํ์ผ์ ์นํฉ์์ ๋์ ์ผ๋ก ๋น๋๋๋ฏ๋ก ์ด๊ฒ์ require()๋ก ๋ก๋๋ค.
const {AppServerModuleNgFactory, LAZY_MODULE_MAP} = require('./dist/server/main');
// ์ ๋๋ฒ์
์ต์คํ๋ ์ค ์์ง(https://github.com/angular/universal/tree/master/modules/express-engine์์ ์ฐพ์ ์ ์์)
app.engine('html', ngExpressEngine({
๋ถํธ์คํธ๋ฉ: AppServerModuleNgFactory,
๊ณต๊ธ์: [
์ ๊ณต ๋ชจ๋ ๋งต(LAZY_MODULE_MAP)
]
}));
app.set('๋ณด๊ธฐ ์์ง', 'html');
app.set('๋ณด๊ธฐ', DIST_FOLDER);
// Express Rest API ์๋ํฌ์ธํธ ์์
// app.get('/api/ *', (req, res) => { });// /browser์์ ์ ์ ํ์ผ ์ ๊ณตapp.get(' .*', express.static(DIST_FOLDER, {
maxAge: '1๋
'
}));
// ๋ชจ๋ ์ผ๋ฐ ๊ฒฝ๋ก๋ ์ ๋๋ฒ์ค ์์ง์ ์ฌ์ฉํฉ๋๋ค.
app.get('*', (์์ฒญ, ํด์๋) => {
res.render('์์ธ', { ์์ฒญ });
});
// ๋
ธ๋ ์๋ฒ ์์
app.listen(ํฌํธ, () => {
console.log( Node Express server listening on http://localhost:${PORT}
);
});
ํ์ฌ๋ก์๋ ์ด๊ฒ์ด ์๋ํด์ผ ํฉ๋๋ค.
@tjoskar ๊ทํ์ ๋ถ๊ธฐ๋ฅผ ์ฌ์ฉํ์ผ๋ฉฐ ๋น๋ ์ค๋ฅ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ ๊ฒ ๊ฐ์ต๋๋ค. ์ธ์ ๋ณํฉํ์ฌ ์ถ์ํ ๊ณํ์ด ์์ต๋๊น?
@Loutrinos , ๋ฆ์ด์ ์ฃ์กํฉ๋๋ค. [email protected]
(๋ฒ ํ)๋ฅผ ์ค์นํ์ฌ ๋ฌธ์ ๊ฐ ํด๊ฒฐ๋๋์ง ํ์ธํ ์ ์์ต๋๊น? ๊ฐ์ฌ ํด์.
@tjoskar 5.1.0 ๋ฆด๋ฆฌ์ค์์ ๊ตฌ์กฐ๊ฐ ๋ค๋ฅด๋ค๋ ๊ฒ์ ์ ์ ์์ต๋๋ค. ๋ฒ ํ ๋ฆด๋ฆฌ์ค์ด๋ฏ๋ก ์ง๊ธ์ ๊ด์ฐฎ์ต๋๋ค.
5.1.0
Angular Universal์ ๋ ์ด์ ๊นจ์ง์ง ์์ต๋๋ค :P
@๋ฃจํธ๋ฆฌ๋ ธ์ค
5.1.0 ๋ฆด๋ฆฌ์ค์์ ๊ตฌ์กฐ๊ฐ ๋ค๋ฅธ ๊ฒ์ ๋ด ๋๋ค.
์ฃ์กํฉ๋๋ค. ์ด์ ๊ณผ ๋์ผํ ๊ตฌ์กฐ๋ก ์ ๋ฆด๋ฆฌ์ค([email protected])๋ฅผ ๋ง๋ค์์ต๋๋ค. ์ง๋ ๋ช ์ฃผ๊ฐ์ ๋งค์ฐ ๋ฐ๋นด์ง๋ง ์ด์ ๋ค์ ์ ๋ฌด์ ๋ณต๊ทํ ์ ์์ผ๋ฏ๋ก ์ด๋ป๊ฒ ํ๋ฉด ๋๋์ง ์๋ ค์ฃผ์ธ์.
5.1.1 ๋ฒ์ ์ ์ค์นํ ํ ๋ค์ ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค.
ReferenceError: IntersectionObserver is not defined
@agustintarifa tsconfig.json
ํ์ผ์ ์ด๋ป๊ฒ ์๊ฒผ๋์?
๋ฐฉ๊ธ ์ด ๋ฆฌํฌ์งํ ๋ฆฌ๋ฅผ ๋ง๋ค์์ต๋๋ค: https://github.com/tjoskar/ng-lazyload-image-bugs/tree/master/370-universal-starter-compile ํ๊ณ ์ ์๋ํฉ๋๋ค. https://github.com/angular/universal-starter ๋ณต์ ํ๊ณ ng-lazyload-image
(npm install [email protected] ์ค์น)๋ฅผ ์ค์นํ๊ณ npm run build:prerender
์ปดํ์ผ๋ ์ด๋ฏธ์ง๋ฅผ ์ถ๊ฐ ํ๊ณ ๊ทธ๋ฐ ๋ค์ node dist/server.js
์๋ฒ๋ฅผ ์์ํ์ต๋๋ค.
@tjoskar ๋ต๋ณ ๊ฐ์ฌํฉ๋๋ค.
์ง๊ธ ์๋ํ๊ณ ์์ผ๋ฉฐ ๋ชจ๋์ ๋ณ๊ฒฝํ์ต๋๋ค.
app.module ์ฌ์ฉ: LazyLoadImageModule.forRoot({}),
๊ทธ๋ฆฌ๊ณ ๋ค๋ฅธ ๋ชจ๋์์: LazyLoadImageModule.forRoot({
preset: intersectionObserverPreset,
}),
์ ์ผํ ๋ฌธ์ ๋ ์คํ์ ์ด ๋งจ ์์์ ์๋ํ์ง ์์ ์ฒซ ๋ฒ์งธ ์ด๋ฏธ์ง๋ฅผ ๋ณด๋ ค๋ฉด ์ต์ํ 1px๋ฅผ ์คํฌ๋กคํด์ผ ํ๊ณ ๋ค๋ฅธ ์ด๋ฏธ์ง๊ฐ ํ์๋ ๋ ๋ก๋ํด์ผ ํฉ๋๋ค. ๊ทธ ์ ์ ์ด๋ฏธ์ง๋ฅผ 200px ๋ก๋ํ๊ณ ์ถ์ต๋๋ค.
HUMM๋ ..์์ ๋ด ์์ ์ ๋ ๋จ์ง ์ ์ธ LazyLoadImageModule
์์ app.module
ํ๊ณ ์ ์๋ํ๊ณ ์ ๋ง ์ค๋ฅ๋ฅผ ์ฌํ ํ ์ ์์ต๋๋ค. ๋๊ตฐ๊ฐ๊ฐ ์ค๋ฅ๋ฅผ ์ฌํํ๊ธฐ ์ํด ์์ ์ ์ฅ์๋ฅผ ๋ง๋ค ์ ์๋ค๋ฉด(๋๋ ๋จ๊ณ๋ณ ์ง์นจ์ ์ ๊ณตํ ์ ์๋ค๋ฉด) ๋งค์ฐ ๋์์ด ๋ ๊ฒ์
๋๋ค.
@agustintarifa , ์คํ์ ๋ฌธ์ ์ ๋ํด. ๋น์ ์ ๊ทธ๊ฒ์ ๋ํ ์๋ก์ด ๋ฌธ์ ๋ฅผ ๋ง๋ค ์ ์์ต๋๊น?
์๋ ํ์ธ์, ๋ฒ ํ๊ฐ ์๋ ์์ ์ ์ธ v5.1.1์ ์ธ์ ๊ธฐ๋ํ ์ ์์ต๋๊น? SSR์๋ ์ด ๋ฌธ์ ๊ฐ ์๊ธฐ ๋๋ฌธ์ ๋๋ค.
@vytautas-pranskunas-, ๋ค๋ฅธ ์์ ์์ ์ฌํญ๊ณผ ํจ๊ป ๋ด์ผ ์ถ์ํ ์์ ์ ๋๋ค.
๋๋จํด ๐
2019๋
4์ 1์ผ ์์์ผ ์คํ 9:17 Oskar Karlsson [email protected]
์ผ๋ค:
@vytautas-pranskunas- https://github.com/vytautas-pranskunas- , ๋๋
๋ค๋ฅธ ์์ ์์ ์ฌํญ๊ณผ ํจ๊ป ๋ด์ผ ๋ฆด๋ฆฌ์คํ์ญ์์ค.โ
๋น์ ์ด ์ธ๊ธ๋์๊ธฐ ๋๋ฌธ์ ์ด๊ฒ์ ๋ฐ๋ ๊ฒ์ ๋๋ค.
์ด ์ด๋ฉ์ผ์ ์ง์ ๋ต์ฅํ๊ณ GitHub์์ ํ์ธ
https://github.com/tjoskar/ng-lazyload-image/issues/370#issuecomment-478709421 ,
๋๋ ์ค๋ ๋ ์์๊ฑฐ
https://github.com/notifications/unsubscribe-auth/ADvMl18aKahOsS6vr4C4h4Tagwy2p4TNks5vclsrgaJpZM4Z0lGg
.
[email protected]
์ด(๊ฐ) ์ถ์๋์์ต๋๋ค. ์ค๋ฅ๊ฐ ๊ณ์ ๋ฐ์ํ๋ค๊ณ ์๋ ค์ฃผ์ญ์์ค.
@tjoskar ๋๋ 6.0.0
ํ๊ณ ์์ผ๋ฉฐ ๋ฌธ์ ๋ ์ฌ๊ธฐ์์ ๊ณ์๋ฉ๋๋ค.
// app.module.ts
LazyLoadImageModule.forRoot({
preset: intersectionObserverPreset
}),
๊ทธ๋ฆฌ๊ณ SSR ์๋ฒ๋ฅผ ์์ํ ๋ ๋ค์์ ์ป์์ต๋๋ค.
ReferenceError: IntersectionObserver is not defined
์ฐธ์กฐ #396
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
Angular Universal๋ก ๋น๋๋ฅผ ์๋ํ๋ ๋์ ๋์ผํ ๋ฌธ์ ๊ฐ ๋ฐ์ํฉ๋๋ค. @tjoskar
ng-packagr
๋ฅผ ์ฌ์ฉํ์ฌ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ๊ตฌ์ถํ๋ ๊ฒ์ ๋ํด ์๊ฐํด ๋ณด์ จ์ต๋๊น ? FESM2015, FESM5 ๋ฐ UMD ํ์์ผ๋ก ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ๋น๋ํ๊ณ ๋ฒ๋คํ ์ ์์ต๋๋ค.https://github.com/ng-packagr/ng-packaged/blob/master/package.json#L11(ng-packagr์ ์ฌ์ฉํ๋ ์์ ํ๋ก์ ํธ)์ ์ดํด๋ณด์ธ์.