markdown-to-html-pipe icon indicating copy to clipboard operation
markdown-to-html-pipe copied to clipboard

Package is not formatted according to Angular Package Format 4.0 Spec

Open steveblue opened this issue 7 years ago • 7 comments

This package is not formatted according to Package Format 4.0. Please update this package to follow the spec.

https://docs.google.com/document/d/1CZC2rcpxffTDfRDs6p1cfbmKNLA6x5O-NtkJglDaBVs/preview

steveblue avatar Sep 25 '17 23:09 steveblue

@steveblue Do you currently have problems using conclurer/markdown-to-html-pipe?

vknabel avatar Sep 26 '17 07:09 vknabel

@steveblue we will migrate to the package format once problems occur.

vknabel avatar Nov 04 '17 11:11 vknabel

@vknabel The package spec is there to ensure a contract between library developers and Angular. I couldn't import into my app as-is because it doesnt conform to the Package Spec, which would make your package compatible with Closure Compiler. In the future when ABC is released your library will not work with ABC. It already doesnt work with Closure Compiler. Its pretty easy to make it compatible, not sure why you are resisting this change.

steveblue avatar Nov 04 '17 22:11 steveblue

This is primary because your tsconfig is incorrectly formatted. You should be using something like this:

ES2015

{
  "compilerOptions": {
    "target": "es2015",
    "module": "es2015",
    "declaration": true,
    "stripInternal": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "noImplicitAny": false,
    "removeComments": true,
    "allowUnreachableCode": false,
    "moduleResolution": "node",
    "outDir": "./ngfactory",
    "lib": ["es2015", "dom"],
    "skipLibCheck": true,
    "types": []
  },
  "angularCompilerOptions": {
   "genDir": "./ngfactory",
   "strictMetadataEmit": true,
   "skipTemplateCodegen": true,
   "annotateForClosureCompiler": true,
   "flatModuleOutFile": "default-lib.js",
   "flatModuleId": "default-lib",
   "debug": false
  },
  "files": [
    "./tmp/index.ts"
  ],
  "compileOnSave": false,
  "buildOnSave": false
}

ES5

{
  "compilerOptions": {
    "target": "es2015",
    "module": "es5",
    "declaration": true,
    "stripInternal": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "noImplicitAny": false,
    "removeComments": true,
    "allowUnreachableCode": false,
    "moduleResolution": "node",
    "outDir": "./ngfactory",
    "lib": ["es2015", "dom"],
    "skipLibCheck": true,
    "types": []
  },
  "angularCompilerOptions": {
   "genDir": "./ngfactory",
   "strictMetadataEmit": true,
   "skipTemplateCodegen": true,
   "annotateForClosureCompiler": true,
   "flatModuleOutFile": "default-lib.js",
   "flatModuleId": "default-lib",
   "debug": false
  },
  "files": [
    "./tmp/index.ts"
  ],
  "compileOnSave": false,
  "buildOnSave": false
}

steveblue avatar Nov 04 '17 22:11 steveblue

@steveblue I am sorry for closing this issue, but I didn‘t know of the closure compiler compatibility problems or any benefits adopting the package format. Now as I know of it, I will have a deeper look on this.

vknabel avatar Nov 04 '17 23:11 vknabel

Using the package spec is only one step to make this compatible with CC, but it is a huge step.

Other things that need to happen:

import * as marked from 'marked'; cannot be interpreted by CC, at least not yet, so marked needs to be an 'extern' (external script) in the CC world. The problem here is *. If it were import { marked } from 'marked' this would be OK, and marked doesn't have to be an extern. But AFAIK this is not possible with marked because it is distributed as commonjs module. module.exports = require('./lib/marked');

This would mean users of the pipe need to package marked on their own, but that is a good thing because now the pipe is bundler agnostic.

To make TS happy, you could do the following instead:

declare let marked: MarkedStatic;

CC has crazy optimizations that it does to a codebase. It mangles to the nth degree, but CC doesn't mangle strings. Since marked has to be an external script, CC cannot mangle any calls to methods on marked, but it tries to anyways, unless the method is called using bracket syntax.

    public static setOptions(options: MarkedOptions): void {
        marked['setOptions'](options);
    }

I could submit this as a PR, but the change required that removes the marked import is a big change.

steveblue avatar Nov 05 '17 03:11 steveblue

the easiest way to comply with the Angular Package specification (and hence avoid any possible problems arising from differing to it) is to use https://github.com/dherges/ng-packagr it is as easy as creating a public_api.ts file and configuring the library build.

macjohnny avatar Jun 14 '18 06:06 macjohnny