Skip to content

Commit a1c2bfc

Browse files
crisbetodevversion
authored andcommitted
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 a1c2bfc

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

test/karma.conf.js

Lines changed: 1 addition & 1 deletion
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,6 +56,7 @@ 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.
6262
{pattern: 'dist/amd_date_fns.js', included: false, watched: false},

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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,17 @@ var nodeModulesPath = '$NODE_MODULES_BASE_PATH';
3333
/** Path mappings that will be registered in SystemJS. */
3434
var pathMapping = {
3535
'tslib': 'node:tslib/tslib.js',
36-
'moment': 'node:moment/min/moment-with-locales.min.js',
3736
'luxon': 'node:luxon/build/amd/luxon.js',
38-
'date-fns': 'amd_date_fns.js',
39-
'date-fns/locale': 'amd_date_fns_locales.js',
37+
'moment': 'node:moment/min/moment-with-locales.min.js',
4038
'moment/locale': 'node:moment/locale',
4139
'kagekiri': 'node:kagekiri/dist/kagekiri.umd.min.js',
4240

4341
'rxjs': 'node:rxjs/bundles/rxjs.umd.min.js',
4442
'rxjs/operators': 'tools/system-rxjs-operators.js',
43+
44+
// These path mappings are only for the legacy Karma setup.
45+
'date-fns': 'dist/amd_date_fns.js',
46+
'date-fns/locale': 'dist/amd_date_fns_locales.js',
4547
};
4648

4749
/** Package configurations that will be used in SystemJS. */

0 commit comments

Comments
 (0)