Skip to content

Commit 0fae60a

Browse files
committed
fixup! feat(material-date-fns-adapter): add date adapter for date-fns
Fix saucelabs unit tests and the integration test for partial compilation.
1 parent 75bba63 commit 0fae60a

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

test/karma.conf.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ module.exports = config => {
4646
watched: false
4747
},
4848
{pattern: 'node_modules/luxon/build/amd/**/*', included: false, watched: false},
49-
{pattern: 'node_modules/date-fns/**/*', included: false, watched: false},
5049
{pattern: 'node_modules/@material/*/dist/*', included: false, watched: false},
5150
{pattern: 'node_modules/kagekiri/**', included: false, watched: false},
5251

@@ -57,10 +56,11 @@ module.exports = config => {
5756
// The Karma system configuration is built by Bazel. The built System config
5857
// is copied into the "dist/" folder so that the Karma config can use it.
5958
{pattern: 'dist/karma-system-config.js', included: true, watched: false},
59+
{pattern: 'test/karma-test-shim.js', included: true, watched: false},
6060

6161
// We transpile the date-fns bundles to AMD manually since they only ship esm bundles.
62-
{pattern: 'dist/amd_date_fns.js', included: false, watched: false},
63-
{pattern: 'dist/amd_date_fns_locales.js', included: false, watched: false},
62+
{pattern: 'dist/amd_date_fns.js', included: true, watched: false},
63+
{pattern: 'dist/amd_date_fns_locales.js', included: true, watched: false},
6464

6565
// Needed for exposing the RxJS operators through the RxJS UMD bundle. This
6666
// is done for performance reasons since fetching individual files is slow.

tools/linker-process/linker-process.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {readFileSync, writeFileSync} from 'fs';
2-
import {join} from 'path';
2+
import {join, extname} from 'path';
33

44
// These imports to `@angular/compiler-cli` need to explicitly specify the `.js` extension as
55
// otherwise the Bazel NodeJS module resolution would end up resolving the ESM2015 `.mjs` files.
@@ -81,6 +81,14 @@ function generateAmdModuleMappingFile(mappings: Map<string, string>): string {
8181

8282
/** Processes the given file with the Angular linker plugin. */
8383
function processFileWithLinker(diskFilePath: string, fileContent: string): string {
84+
const fileExtension = extname(diskFilePath);
85+
86+
// If the input file is not a JavaScript file, do not process it with the linker
87+
// Babel plugin and return the original file content.
88+
if (fileExtension !== '.js' && fileExtension !== '.mjs') {
89+
return fileContent;
90+
}
91+
8492
// We run the linker with JIT mode so that the processed Angular declarations could be
8593
// run within unit tests that rely on JIT information to be available.
8694
const linkerPlugin = createEs2015LinkerPlugin({fileSystem, logger, linkerJitMode: true});

tools/system-config-tmpl.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ var pathMapping = {
3535
'tslib': 'node:tslib/tslib.js',
3636
'moment': 'node:moment/min/moment-with-locales.min.js',
3737
'luxon': 'node:luxon/build/amd/luxon.js',
38-
'date-fns': 'amd_date_fns.js',
39-
'date-fns/locale': 'amd_date_fns_locales.js',
4038
'moment/locale': 'node:moment/locale',
4139
'kagekiri': 'node:kagekiri/dist/kagekiri.umd.min.js',
4240

@@ -51,6 +49,11 @@ var packagesConfig = {
5149
'.': {defaultExtension: 'js'},
5250
};
5351

52+
// Setup the AMD define method from SystemJS. This allows us to setup
53+
// named AMD modules by simply loading them. This is better than having
54+
// to configure path/module mappings manually here in the System config.
55+
window.define = System.amdDefine;
56+
5457
// Manual directories that need to be configured too. These directories are not
5558
// public entry-points, but they are imported in source files as if they were. In order
5659
// to ensure that the directory imports properly resolve to the "index.js" files within

0 commit comments

Comments
 (0)