diff --git a/package-lock.json b/package-lock.json index 02cca43d..814b8abe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -586,9 +586,9 @@ } }, "@dojo/webpack-contrib": { - "version": "5.0.0-alpha.4", - "resolved": "https://registry.npmjs.org/@dojo/webpack-contrib/-/webpack-contrib-5.0.0-alpha.4.tgz", - "integrity": "sha512-HB2Nf4LfM2H872KmpO5G/G3ozdyhtFtGRxeAZcqaZjjSoE/x0RTT34S3sXSk5pTNC/jnSColb0QTOn4+ToJA4g==", + "version": "5.0.0-alpha.7", + "resolved": "https://registry.npmjs.org/@dojo/webpack-contrib/-/webpack-contrib-5.0.0-alpha.7.tgz", + "integrity": "sha512-MTMfKZcAnq05uO0VKuo/0OB4RzvcyI0pmR1C+s2Rky/Fc9SKcaKalQp8XgHJSCq1tNEpiEdB+nszhktpK5JlOw==", "requires": { "@dojo/framework": "^5.0.0-alpha.3", "acorn": "5.3.0", @@ -12246,9 +12246,9 @@ "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=" }, "psl": { - "version": "1.1.29", - "resolved": "https://registry.npmjs.org/psl/-/psl-1.1.29.tgz", - "integrity": "sha512-AeUmQ0oLN02flVHXWh9sSJF7mcdFq0ppid/JkErufc3hGIV/AMa8Fo9VgDo/cT2jFdOWoFvHp90qqBH54W+gjQ==" + "version": "1.1.31", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.1.31.tgz", + "integrity": "sha512-/6pt4+C+T+wZUieKR620OpzN/LlnNKuWjy1iFLQ/UG35JqHlR/89MP1d96dUfkf6Dne3TuLQzOYEYshJ+Hx8mw==" }, "public-encrypt": { "version": "4.0.3", @@ -14931,9 +14931,9 @@ }, "dependencies": { "@types/node": { - "version": "10.12.12", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.12.tgz", - "integrity": "sha512-Pr+6JRiKkfsFvmU/LK68oBRCQeEg36TyAbPhc2xpez24OOZZCuoIhWGTd39VZy6nGafSbxzGouFPTFD/rR1A0A==" + "version": "10.12.14", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.14.tgz", + "integrity": "sha512-0rVcFRhM93kRGAU88ASCjX9Y3FWDCh+33G5Z5evpKOea4xcpLqDGwmo64+DjgaSezTN5j9KdnUzvxhOw7fNciQ==" }, "@types/webpack": { "version": "4.4.21", diff --git a/src/base.config.ts b/src/base.config.ts index 799ab97b..f576638e 100644 --- a/src/base.config.ts +++ b/src/base.config.ts @@ -142,7 +142,6 @@ function loadRoutingOutlets() { const routesConfig = path.join(basePath, 'src', 'routes.ts'); try { if (existsSync(routesConfig)) { - tsnode.register(); const routes: any[] = require(slash(routesConfig)).default; return routes.map((route) => route.outlet); } @@ -151,6 +150,7 @@ function loadRoutingOutlets() { } export default function webpackConfigFactory(args: any): webpack.Configuration { + tsnode.register(); const extensions = args.legacy ? ['.ts', '.tsx', '.js'] : ['.ts', '.tsx', '.mjs', '.js']; const compilerOptions = args.legacy ? {} : { target: 'es6', module: 'esnext' }; let features = args.legacy ? args.features : { ...(args.features || {}), ...getFeatures('modern') }; diff --git a/src/dev.config.ts b/src/dev.config.ts index e68e12f0..be7a8106 100644 --- a/src/dev.config.ts +++ b/src/dev.config.ts @@ -15,6 +15,7 @@ import * as ManifestPlugin from 'webpack-manifest-plugin'; const WebpackPwaManifest = require('webpack-pwa-manifest'); function webpackConfig(args: any): webpack.Configuration { + const basePath = process.cwd(); const config = baseConfigFactory(args); const manifest: WebAppManifest = args.pwa && args.pwa.manifest; const serviceWorker: string | ServiceWorkerOptions = args.pwa && args.pwa.serviceWorker; @@ -86,7 +87,7 @@ function webpackConfig(args: any): webpack.Configuration { new BuildTimeRender({ ...args['build-time-render'], entries: Object.keys(config.entry!), - useManifest: true + basePath }) ); } @@ -96,7 +97,6 @@ function webpackConfig(args: any): webpack.Configuration { path: outputPath }; - config.devtool = 'inline-source-map'; return config; } diff --git a/src/dist.config.ts b/src/dist.config.ts index 2f0d19e5..acba9f5f 100644 --- a/src/dist.config.ts +++ b/src/dist.config.ts @@ -29,6 +29,7 @@ All rights reserved `; function webpackConfig(args: any): webpack.Configuration { + const basePath = process.cwd(); const config = baseConfigFactory(args); const manifest: WebAppManifest = args.pwa && args.pwa.manifest; const serviceWorker: ServiceWorkerOptions = args.pwa && args.pwa.serviceWorker; @@ -99,7 +100,7 @@ function webpackConfig(args: any): webpack.Configuration { new BuildTimeRender({ ...args['build-time-render'], entries: Object.keys(config.entry!), - useManifest: true + basePath }) ); } diff --git a/test-app/package-lock.json b/test-app/package-lock.json index 83d92ef8..024653a1 100644 --- a/test-app/package-lock.json +++ b/test-app/package-lock.json @@ -29,23 +29,23 @@ } }, "@dojo/framework": { - "version": "5.0.0-alpha.2", - "resolved": "https://registry.npmjs.org/@dojo/framework/-/framework-5.0.0-alpha.2.tgz", - "integrity": "sha512-1dL8/ObjIVW0ZgnyuXy+JKOpc5eCNjEjvIIGKSCShR8QYNvko7xfeY1CzO/Jh/yUV90pufehT0e8fxX82Gq8WQ==", + "version": "5.0.0-alpha.3", + "resolved": "https://registry.npmjs.org/@dojo/framework/-/framework-5.0.0-alpha.3.tgz", + "integrity": "sha512-n6Cy3t7Zu65ceBM3UfqgBUmyM0F3JGUDIahMhXv4JKkXNaXSaUGuWDdBlRoH3LcEJDk6pj6ZV+J4JYiZ4IyPCQ==", "requires": { "@types/cldrjs": "0.4.20", "@types/globalize": "0.0.34", "@webcomponents/webcomponentsjs": "1.1.0", - "cldrjs": "0.4.8", + "cldrjs": "0.5.0", "css-select-umd": "1.3.0-rc0", "diff": "3.5.0", - "globalize": "1.3.0", + "globalize": "1.4.0", "intersection-observer": "0.4.2", "pepjs": "0.4.2", "resize-observer-polyfill": "1.5.0", "tslib": "1.8.1", "web-animations-js": "2.3.1", - "whatwg-fetch": "2.0.4" + "whatwg-fetch": "3.0.0" } }, "@dojo/themes": { @@ -258,9 +258,9 @@ "integrity": "sha512-vsGdkwSCDpWmP80ncATX7iea5DWQemg1UgCW5J8tqjU3lYw4FBYuj89J0CTVomA7BEfvSZd84GmHko+MxFQU2A==" }, "cldrjs": { - "version": "0.4.8", - "resolved": "https://registry.npmjs.org/cldrjs/-/cldrjs-0.4.8.tgz", - "integrity": "sha1-O5lMRk0qMrWsp8XeF6YKh+RdxPk=" + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/cldrjs/-/cldrjs-0.5.0.tgz", + "integrity": "sha1-N76S2NGo5myO4S8TA+0xbYXY6zc=" }, "cli-boxes": { "version": "1.0.0", @@ -460,9 +460,9 @@ } }, "domelementtype": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.2.1.tgz", - "integrity": "sha512-SQVCLFS2E7G5CRCMdn6K9bIhRj1bS6QBWZfF0TUPh4V/BbqrQ619IdSS3/izn0FZ+9l+uODzaZjb08fjOfablA==" + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.1.tgz", + "integrity": "sha512-BSKB+TSpMpFI/HOxCNr1O8aMOTZ8hT3pM3GQ0w/mWRmkhEDSFJkkyzz4XQsBV44BChwGkrDfMyjVD0eA2aFV3w==" }, "domutils": { "version": "1.5.1", @@ -733,11 +733,11 @@ } }, "globalize": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/globalize/-/globalize-1.3.0.tgz", - "integrity": "sha1-xWUkuKz9LOONDJfd/c6zj2RLM5I=", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/globalize/-/globalize-1.4.0.tgz", + "integrity": "sha1-TACnneZ9c5qbf/g7ZrkNAlfCdJM=", "requires": { - "cldrjs": "^0.4.6" + "cldrjs": "^0.5.0" } }, "globby": { @@ -1872,9 +1872,9 @@ "integrity": "sha1-Om2bwVGWN3qQ+OKAP6UmIWWwRRA=" }, "whatwg-fetch": { - "version": "2.0.4", - "resolved": "http://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz", - "integrity": "sha512-dcQ1GWpOD/eEQ97k66aiEVpNnapVj90/+R+SXTPYGHpYBBypfKJEQjLrvMZ7YXbKm21gXd4NcuxUTjiv1YtLng==" + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz", + "integrity": "sha512-9GSJUgz1D4MfyKU7KRqwOjXCXTqWdFNvEr7eUBYchQiVc744mqK/MzXPNR2WsPkmkOa4ywfg8C2n8h+13Bey1Q==" }, "which": { "version": "1.3.1", diff --git a/test-app/src/foo.txt b/test-app/src/foo.txt new file mode 100644 index 00000000..afa334b6 --- /dev/null +++ b/test-app/src/foo.txt @@ -0,0 +1 @@ +hello from a text file diff --git a/test-app/src/main.ts b/test-app/src/main.ts index 012809bd..7f662bc8 100644 --- a/test-app/src/main.ts +++ b/test-app/src/main.ts @@ -9,6 +9,7 @@ import './Bar'; import LazyApp from './LazyApp'; import routes from './routes'; import myTheme from './themes/test-app/theme'; +import test from './test.build'; console.log(myTheme); @@ -18,6 +19,8 @@ if (has('foo')) { console.log('foo'); } +const root = document.getElementById('app'); + const btr = has('build-time-render'); App().then((result) => { @@ -30,7 +33,18 @@ if (!div) { div.id = 'div'; } if (btr) { + test('./src/foo.txt').then((result: string) => { + const nodeBtr = document.createElement('div'); + nodeBtr.id = 'nodeBtr'; + nodeBtr.innerHTML = result; + root!.appendChild(nodeBtr); + }); div.setAttribute('hasBtr', 'true'); +} else { + const nodeBtrCache = document.createElement('div'); + nodeBtrCache.id = 'nodeBtrCache'; + nodeBtrCache.innerHTML = test('./src/foo.txt'); + root!.appendChild(nodeBtrCache); } if (process.env.NODE_ENV === 'production') { @@ -53,7 +67,6 @@ div.textContent = `Built with Build Time Render: ${!!div.getAttribute('hasBtr')} Currently Rendered by BTR: ${has('build-time-render')}`; div.classList.add(...css.root.split(' ')); -const root = document.getElementById('app'); if (div.parentNode === null) { root!.appendChild(div); } diff --git a/test-app/src/test.build.ts b/test-app/src/test.build.ts new file mode 100644 index 00000000..6895e7c9 --- /dev/null +++ b/test-app/src/test.build.ts @@ -0,0 +1,5 @@ +const fs = require('fs'); + +export default function(path: string) { + return fs.readFileSync(path, 'utf-8'); +} diff --git a/tests/integration/build.spec.ts b/tests/integration/build.spec.ts index 7e757f1e..b02c4f40 100644 --- a/tests/integration/build.spec.ts +++ b/tests/integration/build.spec.ts @@ -23,6 +23,9 @@ Currently Rendered by BTR: false` cy.get('meta[name="apple-mobile-web-app-title"]').should(isPwa ? 'exist' : 'not.exist'); cy.get('meta[name="apple-mobile-web-app-status-bar-style"]').should(isPwa ? 'exist' : 'not.exist'); cy.get('link[rel="apple-touch-icon"]').should('have.length', isPwa ? 2 : 0); + + cy.get('#nodeBtr').should('contain', 'hello from a text file'); + cy.get('#nodeBtrCache').should('contain', 'hello from a text file'); } it('dist', () => {