Skip to content

Commit

Permalink
Merge pull request #8 in LFOR/fhirpath.js from webbpack-fs-problem to…
Browse files Browse the repository at this point in the history
… master

* commit '239cb08ea65c55bf7659584f8b174b2a03b645ca':
  Refactoring
  Fixes the problem with 'fs' during the webpack build
  • Loading branch information
plynchnlm committed Apr 30, 2020
2 parents 51d4c5f + 239cb08 commit a10b987
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
This log documents significant changes for each release. This project follows
[Semantic Versioning](http://semver.org/).

## [2.1.3] - 2020-04-28
### Changed
- Removed the need to exclude package "fs" when building

## [2.1.2] - 2020-04-27
### Changed
- ucum-lhc package updated to 4.1.3
Expand Down
27 changes: 27 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module.exports = function (grunt) {
// Load grunt tasks automatically, when needed
require('jit-grunt')(grunt, {
replace: 'grunt-text-replace'
});

// Define the configuration for all the tasks
grunt.initConfig({

replace: {
'antlr4-index': {
src: ['src/parser/generated/*.js'],
overwrite: true,
replacements: [{
from: /'antlr4\/index'/g,
to: "'../antlr4-index'"
}]
}
}

});

grunt.registerTask('updateParserRequirements', [
'replace:antlr4-index'
]);

};
3 changes: 0 additions & 3 deletions browser-build/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ const CopyPlugin = require('copy-webpack-plugin');
*/
function makeBaseConfig() {
return {
node: {
fs: "empty"
},
mode: 'production',
devtool: 'source-map',
output: {
Expand Down
8 changes: 7 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fhirpath",
"version": "2.1.2",
"version": "2.1.3",
"description": "A FHIRPath engine",
"main": "src/fhirpath.js",
"dependencies": {
Expand All @@ -22,6 +22,7 @@
"grunt-cli": "^1.3.1",
"grunt-contrib-connect": "^2.0.0",
"grunt-protractor-runner": "^5.0.0",
"grunt-text-replace": "^0.4.0",
"jasmine-spec-reporter": "^4.2.1",
"jest": "^24.1.0",
"jit-grunt": "^0.10.0",
Expand All @@ -38,7 +39,7 @@
"node": ">=8.9.0"
},
"scripts": {
"generateParser": "cd src/parser; rimraf ./generated/*; java -Xmx500M -cp \"../../antlr-4.7.1-complete.jar:$CLASSPATH\" org.antlr.v4.Tool -o generated -Dlanguage=JavaScript FHIRPath.g4",
"generateParser": "cd src/parser; rimraf ./generated/*; java -Xmx500M -cp \"../../antlr-4.7.1-complete.jar:$CLASSPATH\" org.antlr.v4.Tool -o generated -Dlanguage=JavaScript FHIRPath.g4; grunt updateParserRequirements",
"build": "cd browser-build && webpack && rimraf fhirpath.zip && bestzip fhirpath.zip LICENSE.md fhirpath.min.js fhirpath.r4.min.js fhirpath.stu3.min.js && rimraf LICENSE.md",
"test:unit": "jest",
"test:demo": "npm run build && cd demo && npm run build && grunt test:e2e",
Expand Down
29 changes: 29 additions & 0 deletions src/parser/antlr4-index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// This is a modified version of antr4's index.js, in which
// the "require" statements of two unused classes are commented out
// to avoid introducing a dependency on Node.js' "fs" package.

/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
* Use of this file is governed by the BSD 3-clause license that
* can be found in the LICENSE.txt file in the project root.
*/
exports.atn = require('antlr4/atn/index');
exports.codepointat = require('antlr4/polyfills/codepointat');
exports.dfa = require('antlr4/dfa/index');
exports.fromcodepoint = require('antlr4/polyfills/fromcodepoint');
exports.tree = require('antlr4/tree/index');
exports.error = require('antlr4/error/index');
exports.Token = require('antlr4/Token').Token;
// Commented out to avoid the problem with 'fs' during the webpack build
// exports.CharStreams = require('antlr4/CharStreams').CharStreams;
exports.CommonToken = require('antlr4/Token').CommonToken;
exports.InputStream = require('antlr4/InputStream').InputStream;
// Commented out to avoid the problem with 'fs' during the webpack build
// exports.FileStream = require('antlr4/FileStream').FileStream;
exports.CommonTokenStream = require('antlr4/CommonTokenStream').CommonTokenStream;
exports.Lexer = require('antlr4/Lexer').Lexer;
exports.Parser = require('antlr4/Parser').Parser;
var pc = require('antlr4/PredictionContext');
exports.PredictionContextCache = pc.PredictionContextCache;
exports.ParserRuleContext = require('antlr4/ParserRuleContext').ParserRuleContext;
exports.Interval = require('antlr4/IntervalSet').Interval;
exports.Utils = require('antlr4/Utils');
2 changes: 1 addition & 1 deletion src/parser/generated/FHIRPathLexer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Generated from FHIRPath.g4 by ANTLR 4.7.1
// jshint ignore: start
var antlr4 = require('antlr4/index');
var antlr4 = require('../antlr4-index');


var serializedATN = ["\u0003\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964",
Expand Down
2 changes: 1 addition & 1 deletion src/parser/generated/FHIRPathListener.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Generated from FHIRPath.g4 by ANTLR 4.7.1
// jshint ignore: start
var antlr4 = require('antlr4/index');
var antlr4 = require('../antlr4-index');

// This class defines a complete listener for a parse tree produced by FHIRPathParser.
function FHIRPathListener() {
Expand Down
2 changes: 1 addition & 1 deletion src/parser/generated/FHIRPathParser.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Generated from FHIRPath.g4 by ANTLR 4.7.1
// jshint ignore: start
var antlr4 = require('antlr4/index');
var antlr4 = require('../antlr4-index');
var FHIRPathListener = require('./FHIRPathListener').FHIRPathListener;
var grammarFileName = "FHIRPath.g4";

Expand Down
2 changes: 1 addition & 1 deletion src/parser/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const antlr4 = require("antlr4");
const antlr4 = require("./antlr4-index");
const Lexer = require("./generated/FHIRPathLexer").FHIRPathLexer;
const Parser = require("./generated/FHIRPathParser").FHIRPathParser;
const Listener = require("./generated/FHIRPathListener").FHIRPathListener;
Expand Down

0 comments on commit a10b987

Please sign in to comment.